Re: mail() with images *embedded*
| From: | m u i n a r | Date: | Fri, 24 May 2002 07:36:15 +0000 |
| Subject: | Re: mail() with images *embedded* | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-99058@lists.php.net to get a copy of this message | ||
At 08:44 24.05.02, you wrote:
I used: <img src='cid:piccy.jpg> Which I think was what you had as well. Then in the mime parts: Content-Type: image/jpeg; name="piccy.jpg" Content-Transfer-Encoding: base64 Content-ID: <piccy.jpg> Content-Disposition: inline; filename="piccy.jpg"Thanks! That's quite what I have, but the images are attached below the message, and the images in the message itself are broken :( Here's some code: I'm reading the message into the variable $html_body...
$html_body =
"This is a multi-part message in MIME format.\n"
. "--$boundary\n"
. "Content-Type: text/html; charset=\"iso-8859-1\"\n"
. "Content-Transfer-Encoding:8bit\n"
. "\n"
. "
Then comes the html part, the picture embedded as follows...
<img src=\"cid:01.jpg\" width=\"600\" height=\"75\"></td>
... after the html I have:
$file = "01.jpg";
$path = "/usr/www/users/muinar/rtj/i/newsletter-title.jpg";
$fp = fopen( $path,"r" );
$attachment = fread( $fp,filesize( $path ) );
$attachment = chunk_split( base64_encode( $attachment ) );
fclose( $fp );
$html_body .= "--$boundary\n"
. "Content-Type: image/jpeg; name=\"$file\"\n"
. "Content-Transfer-Encoding: base64\n"
. "Content-ID: <$file>\n"
. "Content-Disposition: inline; filename=\"$file\"\n"
. "\n"
. $attachment . "\n"
. "\n\n";
The encoding works, the message looks fine, just the images are not embedded
but attached. Aaargh :(