Ken2k7 Posted August 8, 2008 Share Posted August 8, 2008 Hi, I'm trying to include an image in an email with the PHP mail() function, but all I get is the text, not the image. Does anyone know how to accomplish this feat? Thanks and much obliged, Ken Link to comment https://forums.phpfreaks.com/topic/118839-solved-php-email-image/ Share on other sites More sharing options...
Jabop Posted August 8, 2008 Share Posted August 8, 2008 Are you setting the header's mime type properly Link to comment https://forums.phpfreaks.com/topic/118839-solved-php-email-image/#findComment-611967 Share on other sites More sharing options...
Ken2k7 Posted August 8, 2008 Author Share Posted August 8, 2008 Are you setting the header's mime type properly Uh nope. I don't know too much about this. I tried HTML. Could you give an example? I can follow that. =) Thanks. Link to comment https://forums.phpfreaks.com/topic/118839-solved-php-email-image/#findComment-611973 Share on other sites More sharing options...
Jabop Posted August 8, 2008 Share Posted August 8, 2008 I created a small function that I use for this, just for kicks. <?php function SendMail($To,$Subject,$Body,$From='noreply',$Type='text/html') { $Headers="MIME-Version: 1.0\r\n"; $Headers.="Content-type: ".$Type."; charset=iso-8859-1\r\n"; $Headers.="From: Yoursite.com <".$From."@yoursite.com>\r\n"; $Headers.="Reply-To: ".$From."@yoursite.com\r\n"; mail($To,$Subject,$Body,$Headers,"-f ".$From."@yoursite.com"); } ?> Link to comment https://forums.phpfreaks.com/topic/118839-solved-php-email-image/#findComment-611980 Share on other sites More sharing options...
jake2891 Posted August 8, 2008 Share Posted August 8, 2008 Basically if your storing an image in a directory you need to search that directory for the image path then put it into the email script. But for the image to be displayed by the recipient you need to give it an absolute path for example. '<img src="http://'.$_SERVER['HTTP_HOST'].'/'.$image_path.'" />'; let me know if ur still stuck Link to comment https://forums.phpfreaks.com/topic/118839-solved-php-email-image/#findComment-611983 Share on other sites More sharing options...
Ken2k7 Posted August 8, 2008 Author Share Posted August 8, 2008 Thanks Jabop. I'll update when I verify its functionality. =) Link to comment https://forums.phpfreaks.com/topic/118839-solved-php-email-image/#findComment-611996 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.