well I have progressed but its still not working 100% this is what i have done for now: The email gets received and the size of the email is correct according to the attachment but the problem I'm having is that the attachment doesnt have the correct content, ie: if its a powerpoint slide it takes forever to open and doesnt have anything in it. I see that Content-Transfer-Encoding is set to quoted-printable, should this not be set to "Content-Transfer-Encoding: base64\r\n"; ??? as you can see that the content is being encoded using base64_encode(); Im not too sure about that part. What is quoted-printable and why would I use either that or base64_encode() over one another? code below, thanks again in advance $to="heatherzn@xxxxxxxxx"; $mime_boundary = "<<<--==+X[".md5(time())."]"; //Sort out your basic headers as usual, by piling them into a $headers string. $headers .= "From: binc2 <binc2@xxxxxxxxxx>\r\n"; $headers .= "To: bingi <heatherzn@xxxxxxxxx>\r\n"; //Then you've got to specify the type of content you're dealing with. This is also put into the $headers string. In this case, it will be mixed between text, and some kind of attachment, hence the Content-Type bit. The boundary bit uses the boundary variable you made earlier: $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: multipart/mixed;\r\n"; $headers .= " boundary=\"".$mime_boundary."\""; //Next, get on with piling the message into a $message string. You need quite a bit of header looking stuff in here. The first bit is what is displayed if the client receiveing the email doesn't support MIME, followed by the boundary string (preceded by "--", not sure why). $message .= "This is a multi-part message in MIME format.\r\n"; $message .= "\r\n"; $message .= "--".$mime_boundary."\r\n"; //Next comes the actual content of the email, each part needs it's own mini header describing what it is. $message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\r\n"; $message .= "Content-Transfer-Encoding: 7bit\r\n"; $message .= "\r\n"; $message .= "Email content and what not: \r\n"; $message .= "This is the file you asked for! \r\n"; $message .= "--".$mime_boundary."\r\n"; //Finally, a plaintext attachment. In this case I already put your contents into $fileContent. $message .= "Content-Type: application/octet-stream;\r\n"; $message .= " name=/home/httpd/vhosts/futurealpha.com/httpdocs/pps/049.jpg\r\n"; $message .= "Content-Transfer-Encoding: quoted-printable\r\n"; $message .= "Content-Disposition: attachment;\r\n"; $message .= " filename=\"049.jpg\"\r\n"; $message .= "\r\n"; //content of the attachment section $pps= "/home/httpd/vhosts/futurealpha.com/httpdocs/pps/049.jpg"; $pps_size=(filesize($pps)); $fp = fopen($pps,'rb'); $file = fread($fp, $pps_size); /* Encode The Data For Transition using base64_encode(); And get a 32-character hexadecimal number */ $fileContent .= chunk_split(base64_encode($file)); $message .= $fileContent; $message .= "\r\n"; $message .= "--".$mime_boundary."\r\n"; $ok = mail($to, "file by email", $message, $headers); >>> Manuel Lemos <mlemos@xxxxxxx> 11/15/2004 5:26:25 PM >>> Hello, On 11/15/2004 12:28 PM, Angelo Zanetti wrote: > I have a script that is supposed to use the mail function to send an > email with an attachment, however, when run the script I dont get any > errors but in the body of the email there is a lot of mixed up text, > which i presume is meant to be the attachment. That is because you are setting it to be of text/plain. Anyway, although you can, you should not be sending messages with attachments this way as modern spam filters will discard your messages. You may want to try this class to compose and send messages with attachments properly: http://www.phpclasses.org/mimemessage -- Regards, Manuel Lemos PHP Classes - Free ready to use OOP components written in PHP http://www.phpclasses.org/ PHP Reviews - Reviews of PHP books and other products http://www.phpclasses.org/reviews/ Metastorage - Data object relational mapping layer generator http://www.meta-language.net/metastorage.html -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php