RE: Sending attachments via mail()
| From: | Daniel BI | Date: | Wed, 16 May 2001 17:42:45 +0000 |
| Subject: | RE: Sending attachments via mail() | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-53079@lists.php.net to get a copy of this message | ||
Yep, it was *very* much discussed last time :)
first need to prepare your image to meet the base 64
and chunked standards:
$content = chunk_split ( base64_encode ( $your_image ) );
then you need something like this in the additional
header info of the php mail function:
$boundary = 'NEXT_PART';
$head = "Content-Type: multipart/mixed; boundary='$boundary'\n";
$head .= "Mime-Version: 1.0\n";
then in the message:
$message = "--$boundary\n";
$message .= "Content-Type: image/jpeg; name='my_image.jpg'\n";
$message .= "Content-Transfer-Encoding: base64\n";
$message .= "Content-Disposition: attachment\n\n";
$message = $content;
That's all! and it works! This way you can include html content too,
changing the content-type.
hope it helps.
Daniel BI