images shown in Outlook Express but not in Outlook 2003

Skip to first unread message


Feb 8, 2007, 4:29:47 AM2/8/07
to mimemessage-dev
I'm writing a php code to send email in mime format.
All seams ok if I read the email with outlook express, or Thunderbird,
or any webmail, but if I open the email with Outlook 2003, I can't see
the images, I just see a small box (I send 1 image) with inside the
path of the image.
The image is embedded in the message, it's not a link.
What am I doing wrong???
Here is the code:

$header = "From: Sender <>\n";
$header .= "CC: Altro Ricevente <>\n";
$header .= "X-Mailer: Our Php\n";

$boundary = "==String_Boundary_x" .md5(time()). "x";
$boundary2 = "==String_Boundary2_y" .md5(time()). "y";

$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/related;\n";
$header .= " type=\"multipart/alternative\";\n";
$header .= " boundary=\"$boundary\";\n\n";

$messaggio = "If you read this, your email client doesn't support MIME

$message .= "--$boundary\n";
$messag .= "Content-Type: multipart/alternative;\n";
$message .= " boundary=\"$boundary2\";\n\n";

$message .= "--$boundary2\n";
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= "Alternative message in plain text format.\n\n";

$message .= "--$boundary2\n";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n";
$message .= "Content-Transfer-Encoding: 7bit\n\n";
$message .= "<html><body><p>This message is in <i>html</i> format but
has a plain text part.</p><p>Visit the website <a href=\"http://\"></a><img src=\"cid:image1\"></p></

$message .= "--$boundary2--\n";

$message .= "--$boundary\n";
$message .= "Content-ID: <image1>\n";
$message .= "Content-Type: image/jpeg\n";
$message .= "Content-Transfer-Encoding: base64\n\n";

$attached = "./images/image1.jpg";
$file = fopen($attached,'rb');
$data = fread($file,filesize($attached));

$data = chunk_split(base64_encode($data));
$message .= "$data\n\n";

$message .= "--$boundary--\n";

$subject = "message with inline(embedded) image";

if( @mail("", $subject, $message, $header) ) echo
"e-mail sent!";
else echo "error sending the e-mail!";

Reply all
Reply to author
0 new messages