I’m trying to send an email from a webpage that contains a file attachment (resume) loaded by visitor to the website.
I have tried to use formmail but it appears dreamhost doesn’t use or allow the attachment facility and suggest another route.
so… I’ve tried using a php script to send.
…and I have one that appears to work except the attachments appear all garbled.

I’m not sure if I have a problem with the script or it the issus is with mail server side??

The issue apears to be similar to this:
From another Forum

I encode an attachment using “$encoded_attach = chunk_split(base64_encode($contents));” on a new ISP and it emails a corrupted file?
Finally found the answer to my own question…

I needed to set the following variable before executing the encryption:

set_magic_quotes_runtime(0);

The file was corrupted on the new ISP since they have this set to 1 on their system and the old ISP had it at 0. This does not parse the encryped file with slashes for special characters.

I tried this but it isn’t working form me.
Here is my code for what it’s worth. Looking for directions.
OR BETTER ALTERNATIVE.

You will receive a copy of this email

Thank you.

Your problem is you got the format of the message all wrong. Perhaps it would help if you changed the variable names to full words instead of abbreviations.

$headers should contain only he headers for the message itself.
$message should contain the different parts of the message.
Let’s add $part to represent a part.
Let’s add $part_headers and $part_body to represent the parts of a part.

Ok, I’ve added the
"Content-Type: text/plain
Content-Transfer-Encoding: 7bit"
to be included in the body… but that doesn’t appear to be the problem.
Regardless of where the message header (Body part header the "plain text stuff) gets placed… I’m still not seeing the contents of my file… all garbled. This is the problem… if syntax is the issue then i’d by that… but.
…

Regardless of where the message header (Body part header the "plain text stuff) gets placed… I’m still not seeing the contents of my file… all garbled. This is the problem… if syntax is the issue then i’d by that… but.

The first blank line marks the end of the headers and the beginning of the body, so it’s important that no program add a blank line in the middle of the headers. This is a common error by novice programmers trying to write a program or script to generate e-mail messages.

And to understand where you went wrong with the message headers, read:

I really appreciate your assistance and I maybe struggling with “The Basic Syntax” =… But I thought I had it.

I’m getting an email (I expect) - with what appears to be appropriate headers, with the appropriate body message I expect.

What I’m having problems with is the Attachment.
I played around last night and …I can get a plain text attachment but not a msword or pdf. Something to do with the encode and decode base 64 stuff. - is causing the garbled messages. Now if you says that is a result of my syntax errors with formatting headers etc. then I guess I’ll have to get some more education.

FYI, the mime link appears to be broken.

(Geeze… I was looking for a simple function, which someone else had provide a ready made solution)

Something to do with the encode and decode base 64 stuff. - is causing the garbled messages. Now if you says that is a result of my syntax errors with formatting headers etc. then I guess I’ll have to get some more education.

Well now your script it is not putting the base64 encoding of the file in the message at all.

You still have the parts of the message improperly formatted. It’s not freakin’ hard. It goes like
this

–BOUNDARY
HEADER: VALUE
HEADER: VALUE

BODY LINE
BODY LINE

Now you’ve got it like
–BOUNDARY
HEADER: VALUE
HEADER: VAL
UE
BODY LINE
BODY LINE

You will receive a copy of this email

Thank you.

[code]function mime_part($boundary, $body, $type, $charset, $disposition, $filename, $encoding) {
/*
This function returns a string value representing a MIME part.
These arguments are optional: $charset, $filename, and $encoding.
$encoding should be set if $body is not a multipart entity.
*/