anyone on this...

a few have suggested "install this class" and so forth.  That is not the point.
the goal is to correctly format and encode the simple message with attachment so
we can customize things from there.  The classes available for this are great,
but defeat the purpose of understanding.

looking forward to comments or suggestions.


>-----Original Message-----
>From: Dave [mailto:[EMAIL PROTECTED]]
>Sent: Tuesday, June 04, 2002 5:45 PM
>Subject: [PHP] problems with attachment to email for mail() function
>have a form where user uploads "attachment" and provides email address and a
>brief note regarding the attachment.  The below script should grab all that and
>email the note with the attachment to our target user.
>Email appears with text portion and attachment icon, but no attachment (Outlook
>2000).  In viewing the email prior to delivery to the client, it appears to be
>formatted correctly.  The following is the email script, and below that the
>headers from the email.
>if \n is replaced with \r\n then no attachment flag appears, otherwise same
>help or insight appreciated.
>>> php file code
># $from, $to, $body, and $attachment are provided in the previous form
>$sig = "\n--\nWebsite Mailer\n";
>$body .= $sig;
>$headers = "From: $from\n";
>$boundary = "=====WSM." . md5(uniqid(time())) . "=====";
>$headers .= "MIME-Version: 1.0\n";
>$headers .= "Content-Type: multipart/mixed;\n\tboundary=\"$boundary\"\n\n";
>$str = "--$boundary\n";
>$str .= "Content-Type: text/plain;\n\tcharset=\"us-ascii\"\n";
>$str .= "Content-Transfer-Encoding: 7bit\n\n";
>$str .= "$body\n\n";
>$fp = fopen($attachment, "rb");
>$data = fread($fp, filesize($attachment));
>$data = chunk_split(base64_encode($data),76,"\n");
>$str .= "--$boundary\n";
>$str .= "Content-Type: ".$attachment_type.";\n\tname=\"".$attachment_name .
>$str .= "Content-Transfer-Encoding: base64\n";
>$str .= "Content-Disposition: attachment; \n\tfilename=\"".$attachment_name .
>$str .= $data;
>$str .= "--$boundary--\n";
>$body = $str;
>if(mail($to, $subject, $body, $headers)){
>       $status.='<br>Successfully sent.';
>       $status.='<br>An error occurred while sending.';
>>>email header info
>Return-Path: <[EMAIL PROTECTED]>
>Delivered-To: [EMAIL PROTECTED]
>Received: (qmail 96549 invoked by uid 81); 4 Jun 2002 21:45:49 -0000
>Date: 4 Jun 2002 21:45:49 -0000
>MIME-Version: 1.0
>Content-Type: multipart/mixed;
>        boundary="=====WSM.38ef75d9c66623ee87e302bad63e79b3====="
>Content-Type: text/plain;
>        charset="us-ascii"
>Content-Transfer-Encoding: 7bit
>Website Mailer
>Content-Type: application/octet-stream;
>        name=""
>Content-Transfer-Encoding: base64
>Content-Disposition: attachment;
>        filename=""
>PHP General Mailing List (
>To unsubscribe, visit:

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to