Log in

View Full Version : Send images into the mail



dardanel
07-20-2006, 03:21 PM
HI! ...Can someone tell me haw can i send an email with pictures. I know a way by putting the link to the images(for example: <img src="http://picture.jpg">) ...but i need to send a picture into the mail ...and when you open the mail you will see that picture into that mail ...not atached to that mail.
THANKS!!!

viper102464
07-21-2006, 06:23 AM
<?php

//variables

$to = //your email address
$subject = //subject
$headers = "MIME-Version: 1.0\r\n".
"Content-type: text/html; charset=iso-8859-1\r\n".
"From: Whoever";

$message = "
<html>
<body>
<img src=\"http://www.yoursite.com/yourimage.jpg\"border=\"0\" alt=\"\">
</body>
</html>
";

//Mail Function

mail($to,$subject,$message,$headers);
echo "Your picture has been sent!";

?>

Hope that helps, if not, sorry.:) :)

Twey
07-21-2006, 06:40 AM
It is possible, but it's a little complex. You must be using MIME email. You can then send the boundary followed by the headers:
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-ID: <part2.04060903.01030906>This is followed by two CRLFs, the image in base64_encode (http://www.php.net/base64-encode)()ed format, another CRLF, then the boundary. You can then reference the image by its Content-ID, like so:
<img
src="cid:part2.04060903.01030906">

dardanel
07-21-2006, 02:33 PM
Thanks for the answer!!!

Thanks viper102464 ...but that write into the email message the url to the image ...and when you open the email they ask you if you want to see the picture or not ....but if you do it like Tway said then you will see the image widout asking you if you want to see the picture or not.

Thanks Twey!!! ...that is what i needed! ;)
THANKS A LOOOTTT!!!