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 Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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"); } ?> Quote Link to comment 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 Quote Link to comment 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. =) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.