note 21882 deleted from ref.mail by dams
| From: | dams@php.net | Date: | Thu, 30 May 2002 15:13:23 +0000 |
| Subject: | note 21882 deleted from ref.mail by dams | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-31209@lists.php.net to get a copy of this message | ||
This is some quick code to get attachments working (for not only Outlook, like many other examples i
found on the web). You have to put in code to make proper boundaries and read files etc, but I
presume that if you're searching for this piece of code, you already know how to do that.
<?php
$enter = "\r\n";
$headers[] = "MIME-Version: 1.0";
$headers[] = "Content-Type: multipart/mixed;";
$headers[] = " boundary=\"blabla\"";
$headers[] = "This is a multi-part message in MIME format.";
$headers[] = "--blabla";
$headers[] = "Content-Type: multipart/text;";
$headers[] = "";
$headers[] = "contents of the text part!";
$headers[] = "--blabla";
$headers[] = "Content-Type: application/octet-stream;";
$headers[] = " name=\"file description\"";
$headers[] = "Content-Transfer-Encoding: base64";
$headers[] = "Content-Disposition: attachment;";
$headers[] = " filename=\"file name\"";
$headers[] = "";
$headers[] = chunk_split(base64_encode("contents of file"));
$headers[] = "";
$headers[] = "--blabla--";
mail( 'foo@bar.nl', 'test', '', join($enter,$headers) );
?>
Jan David Mol,
The Netherlands