asmith Posted January 4, 2008 Share Posted January 4, 2008 is that possible i send an image with mail function ? for example if i want to put an i mage inside my HTML mail message : $msg = <b>welcome</b> this is a picture <img src="???" title="welcome" /> ?? thanks Link to comment https://forums.phpfreaks.com/topic/84466-send-image-with-mail-function/ Share on other sites More sharing options...
pkSML Posted January 4, 2008 Share Posted January 4, 2008 You could use PHP Mailer. It allows you to include attachments. URL: http://sourceforge.net/project/showfiles.php?group_id=26031 Homepage: http://sourceforge.net/projects/phpmailer Link to comment https://forums.phpfreaks.com/topic/84466-send-image-with-mail-function/#findComment-430357 Share on other sites More sharing options...
asmith Posted January 4, 2008 Author Share Posted January 4, 2008 for attaching a simple image i don't want to go through php mailer. sometimes i'd like to put a 300 b image as a background . so it's not possible through php built-in functions? Link to comment https://forums.phpfreaks.com/topic/84466-send-image-with-mail-function/#findComment-430364 Share on other sites More sharing options...
pkSML Posted January 4, 2008 Share Posted January 4, 2008 To do this the easy way, have your background available on the web. Then just create a simple HTML email. For example: <?php $from = "[email protected]"; $to = "[email protected]"; $subject = "Hello!"; $headers = "From: {$from}\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n\r\n"; $message = '<HTML> <HEAD> <TITLE></TITLE> </HEAD> <BODY background="http://us.i1.yimg.com/us.yimg.com/i/us/sch/gr/bggreendiag.gif"> message goes here <img height=1 width=1 src="http://pksml.net/blank.gif"> </BODY> </HTML>'; //send message if (mail("$to", "$subject", "$message", "$headers")) {echo "Mail sent!";} else {echo "Mail NOT sent!";} ?> Notice the background in the body tag of the HTML message. To show pictures, I found it necessary to place one in the body of the HTML, so I just put a blank transparent picture there. Link to comment https://forums.phpfreaks.com/topic/84466-send-image-with-mail-function/#findComment-430459 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.