d.shankar Posted July 30, 2008 Share Posted July 30, 2008 Hi all. I got this email script and it really irritates me a lot. I need this email to be sent in html format. When opened it should display the image and other formattings. But nothing is working it seems. I have tried this mail by sending to my gmail and it shows the image but i am not able to see the image in any other email accounts.. say yahoo,hotmail,webmail...etc Here is the php email script <?php $to="[email protected]"; $subject="testing"; $message="<img src='http://l.yimg.com/t/img/new_in_fp_logo.gif'><br>This is a mail from yahoo india<br>"; $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $headers .= "Message-ID: <".$now." TheSystem@".$_SERVER['SERVER_NAME'].">\r\n"; $headers .= "X-Mailer: PHP v".phpversion()."\r\n"; $message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; mail($to,$subject,$message,$headers); ?> Can someone help me out ? Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/ Share on other sites More sharing options...
MasterACE14 Posted July 30, 2008 Share Posted July 30, 2008 I believe this should be in the header. "Content-Type:text/html; charset=\"iso-8859-1\" Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-603353 Share on other sites More sharing options...
d.shankar Posted July 30, 2008 Author Share Posted July 30, 2008 It is already in the $message variable Shall i remove it from the $message variable and add it to the header ? Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-603355 Share on other sites More sharing options...
monkeypaw201 Posted July 30, 2008 Share Posted July 30, 2008 Try it, and let us know Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-603369 Share on other sites More sharing options...
d.shankar Posted July 30, 2008 Author Share Posted July 30, 2008 I am sorry to say that it isnt working Here is the code... <?php ini_set("sendmail_from", "The Yahoo Team <[email protected]>"); $to="[email protected]"; $subject="testing1"; $message="<img src='http://l.yimg.com/t/img/new_in_fp_logo.gif'><br>This is a mail from yahoo india<br>"; $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . " boundary=\"{$mime_boundary}\""; mail($to,$subject,$message,$headers); ?> Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-603375 Share on other sites More sharing options...
d.shankar Posted July 30, 2008 Author Share Posted July 30, 2008 This is what i receive to my mail MIME-Version: 1.0 Content-Type:text/html; charset="iso-8859-1" boundary="==Multipart_Boundary_xx" <img src='http://l.yimg.com/t/img/new_in_fp_logo.gif'><br>This is a mail from yahoo india<br> Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-603379 Share on other sites More sharing options...
d.shankar Posted July 30, 2008 Author Share Posted July 30, 2008 Bump1 Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-603423 Share on other sites More sharing options...
d.shankar Posted August 1, 2008 Author Share Posted August 1, 2008 This code works fine when i send the mail from my localhost .. but when i host this script in the server i get the mail as shown above with tags being shown. Can someone helpme ? Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-605416 Share on other sites More sharing options...
d.shankar Posted August 2, 2008 Author Share Posted August 2, 2008 I have shortened down the code... it still works from my localhost , but it does not work in from my live server. <?php ini_set("sendmail_from", "The Yahoo Team <[email protected]>"); $to="[email protected]"; $subject="testing1"; $message="<img src='http://l.yimg.com/t/img/new_in_fp_logo.gif'><br>This is a mail from yahoo india<br>"; $headers .= "\nMIME-Version: 1.0\n"."Content-Type:text/html; charset=\"iso-8859-1\"\n"; mail($to,$subject,$message,$headers); ?> Please somebody help :'( Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-605912 Share on other sites More sharing options...
Andy-H Posted August 2, 2008 Share Posted August 2, 2008 Duno but you should close your image and br tags with /> Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-605918 Share on other sites More sharing options...
d.shankar Posted August 2, 2008 Author Share Posted August 2, 2008 Still not working Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-605919 Share on other sites More sharing options...
JasonLewis Posted August 2, 2008 Share Posted August 2, 2008 Try this: <?php error_reporting(E_ALL); ini_set("sendmail_from", "The Yahoo Team <[email protected]>"); $to = "[email protected]"; $subject = "testing1"; $message = "<img src='http://l.yimg.com/t/img/new_in_fp_logo.gif' /><br />This is a mail from yahoo india<br />"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; if(mail($to,$subject,$message,$headers)){ //It was sent! echo "Mail has been sent!"; }else{ //Failed to send mail... echo "Mail was not sent!"; } ?> Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-605930 Share on other sites More sharing options...
d.shankar Posted August 2, 2008 Author Share Posted August 2, 2008 Wow it worked ProjectFear ! My deepest thanks to you. I wonder how u did that ? Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-605952 Share on other sites More sharing options...
JasonLewis Posted August 2, 2008 Share Posted August 2, 2008 The only thing I really changed was removing the \n from the start of your $headers variable. And made it a bit more readable. And added error checking. Oh and you can remove error_reporting(E_ALL) if you need to. Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-605956 Share on other sites More sharing options...
d.shankar Posted August 2, 2008 Author Share Posted August 2, 2008 Thank you ProjectFear !!!!!!!!!!!!! Link to comment https://forums.phpfreaks.com/topic/117293-solved-html-email/#findComment-605971 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.