Send Embedded Image to mail

by raveendran 2009-11-07 16:36:12

Normally the image not shown in mail, instead of this we have to click 'show image' link.
But the following code will display the image without clicking 'show image'.


<?php
$eid=$_GET['mail'];
require("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsMail();
$mail->From = "example@mail.com";
$mail->AddAddress("$eid");
$mail->Subject = "sending image to mail";
$mail->IsHTML(true);
$mail->AddEmbeddedImage("image_03.gif","mailimage","image_03.gif","base64","image/gif");
$mail->Body="<table style='border: thin solid #4682B4; border-collapse: collapse;' align='center' width=100%> <tr><td><img src='cid:mailimage'></td></tr></table>";
if(!$mail->Send())
{
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
}
else
echo "Message sent";
?>

Tagged in:

1206
like
0
dislike
0
mail
flag

You must LOGIN to add comments