By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,830 Members | 2,276 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,830 IT Pros & Developers. It's quick & easy.

images shown in Outlook Express but not in Outlook 2003

P: n/a
Hi,
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:

<?php
$header = "From: Sender <sen...@domain.org>\n";
$header .= "CC: Altro Ricevente <blabla...@domain.net>\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
\n\n";

$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</iformat but
has a plain text part.</p><p>Visit the website <a href=\"http://
www.xxxxxx.com\">www.xxxxxxxxx.com</a><img src=\"cid:image1\"></p></
body></html>\n";

$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));
fclose($file);

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

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

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

if( @mail("recei...@domain.com", $subject, $message, $header) ) echo
"e-mail sent!";
else echo "error sending the e-mail!";
?>

Feb 12 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On 12 Feb, 11:30, "Andrea" <andr...@tin.itwrote:
Hi,
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:

<?php
$header = "From: Sender <sen...@domain.org>\n";
$header .= "CC: Altro Ricevente <blabla...@domain.net>\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
\n\n";

$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</iformat but
has a plain text part.</p><p>Visit the website <a href=\"http://www.xxxxxx.com\">www.xxxxxxxxx.com</a><img src=\"cid:image1\"></p></
body></html>\n";

$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));
fclose($file);

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

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

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

if( @mail("recei...@domain.com", $subject, $message, $header) ) echo
"e-mail sent!";
else echo "error sending the e-mail!";
?>
Can you see images in anoy other emails in Outlook?

Feb 12 '07 #2

P: n/a
Andrea wrote:
I'm writing a php code to send email in mime format.
Stop trying to re-invent the wheel!

http://pear.php.net/package/Mail_Mime

--
Toby A Inkster BSc (Hons) ARCS
Contact Me ~ http://tobyinkster.co.uk/contact
Geek of ~ HTML/SQL/Perl/PHP/Python*/Apache/Linux

* = I'm getting there!
Feb 12 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.