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
Express.

       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"
                   ."Content-Type:
multipart/mixed;boundary=\"$mail_boundary\"\r\n"
                   ."\r\n"
                   ."This is a multi-part in MIME format\r\n"
                   ."\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"
                ."\r\n"
                .$body
                ."\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
chunks.
       $filename = basename($attacharray[$i][filename]);
    $mailbody .= "--$mail_boundary\r\n"
              ."Content-Type:
".$attacharray[$i][mimetype].";name="."\"$filename\"\r\n"
              ."Content-Transfer-Encoding: base64\r\n"
              ."Content-Disposition: attachment;"
              ."filename="."\"$filename\"\r\n"
                   ."\r\n"
                   .$file
                   ."\r\n"
                   ."\r\n";
     }

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

$fileattach[] =
array("filename"=>"/home/timeking/product/bigpic/yellowcomb.jpg",
                      "mimetype"=>"image/jpeg");

Mailattachments(("[EMAIL PROTECTED]"),("Subject"),("BodyMessages"),($fileattach)
,("X-mailer"));
?>


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

Reply via email to