Hi All,

        I am trying to do a mail attachment for photo(jpeg file) by using
php mail function and qmail server.  I have used the following mime format
to send out photo attachment provide by
http://planetkiller.shadow.net.au/mime-php.txt.  But When I received the
mail in Outlook Express, they are in garbage like "1253254dfafafadgas".

       And the most funny things is that if the mail message has been
modified on the server before downloading to Outlook Express.  Then, I am
able to received the mail in normal situation when downloaded to Outlook

       By modified I means "just to delete a quote or a word, then add it
back and then save the file".

The code is below.  Any body having any ideas.

Thanks in advance

Mark Lo
Function mailattachments($to,$subject,$body,$attacharray,$extraheaders)
// Generate a unique boundary
 $mail_boundary ="b". md5(uniqid(time()));
// MIME-compliant headers
  $mailheaders = $extraheaders
                   ."MIME-Version: 1.0\r\n"
                   ."This is a multi-part in MIME format\r\n"

// Body. The part that gets displayed as the message:
 $mailbody = "--$mail_boundary\r\n"
                ."Content-Type: text/plain;charset=\"iso-88592\"\r\n"
                ."Content-Transfer-Encoding: 7bit\r\n"

// Now, do the attachments
  for ($i = 0; $i < count($attacharray); $i++)
       $fp = fopen($attacharray[$i][filename], "r");
       $file = fread($fp, filesize($attacharray[$i][filename]));
       $file = base64_encode($file);  // BASE64-encoded. Text. Nice.
       $file = chunk_split($file);    // Now in handy bite-sized 76-char
       $filename = basename($attacharray[$i][filename]);
    $mailbody .= "--$mail_boundary\r\n"
              ."Content-Transfer-Encoding: base64\r\n"
              ."Content-Disposition: attachment;"

// End of mail
  $mailbody .= "--$mail_boundary--";
  mail($to, $subject, $mailbody, $mailheaders);

$fileattach[] =

Mailattachments(("[EMAIL PROTECTED]"),("Subject"),("BodyMessages"),($fileattach)

PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to