View Full Version : sending MIME email in PHP

09-13-2003, 12:58 PM
I wish to create a script on my site that allows a user to e-mail a picture to a friend.

I can do the e-mail bit easily enough - but I want to include the picture as an attachment.

I know i need to use MIME email for this but cant find any useful links on how to get started - anything out there is a bit too complex.

does anyone know any simple starter tutorials? and/or have some code lying around?

09-13-2003, 03:31 PM
I think you would have to include something in the headers. I've seen it before, but I don't know it right off the top of my head.

09-13-2003, 05:45 PM
hold the presses.....

I found and adapted a script that does the job:


which works ok BUT when the "image" arrives in your email it is still in code form. I think the problem comes down to this chunk:

// Add file attachment to the message
$message .= "--{$mime_boundary}\n" .
"Content-Type: {$fileatt_type};\n" .
" name=\"{$fileatt_name}\"\n" .
//"Content-Disposition: attachment;\n" .
//" filename=\"{$fileatt_name}\"\n" .
"Content-Transfer-Encoding: base64\n\n" .
$data . "\n\n" .

As I nabbed.. erm I mean... "borrowed" this code from a script that orignally handled file uploads i think I need to replace the variables $fileatt_name and $fileatt_type with values so that they are JPEG compatible.

Any suggestions??