IsmAvatar Posted April 23, 2008 Share Posted April 23, 2008 I'm sending an html message to an email address with the following code: $email = 'email.html'; $subject = 'Hello world'; $mess = file_get_contents($email); $headers = "MIME-Version: 1.0\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\n"; $headers .= "To: $to\n"; $headers .= "From: $from\n"; mail($to,$subject,$mess,$headers); test.html contains some html code and includes an img src with a full url to the image. I was wondering if there's any other headers I need to add for this to work right, especially in the Mozilla Thunderbird email client. I attempted to send it to myself, and I got the email in its html glory, but the image was blocked, so I told Tbird to unblock it, and the image was still broken (white box square instead of image). The URL works fine because if I load the given html page in my browser, the image shows up. Link to comment https://forums.phpfreaks.com/topic/102556-solved-include-image-in-mail/ Share on other sites More sharing options...
Spaceman-Spiff Posted April 23, 2008 Share Posted April 23, 2008 I don't know how thunderbird works, but make sure you include full url, all with http://www.domainname.com/ stuff. Different mail programs will strip/parse html differently. Some allows more than others. Gmail for example, will strip most 'style' attributes, so you can't use css images. Link to comment https://forums.phpfreaks.com/topic/102556-solved-include-image-in-mail/#findComment-525134 Share on other sites More sharing options...
IsmAvatar Posted April 23, 2008 Author Share Posted April 23, 2008 the url is full. For example: <img src="http://www.phpfreaks.com/images/logo_main.jpg"> does not display in the email. Instead, it appears as a broken image. The HTML code is very simple, with no CSS or anything fancy in there, just <br> tags and an <img src>, along with the <html> and <body> tags Link to comment https://forums.phpfreaks.com/topic/102556-solved-include-image-in-mail/#findComment-525152 Share on other sites More sharing options...
IsmAvatar Posted April 23, 2008 Author Share Posted April 23, 2008 lol... That should read "Just < br > tags and an <img src>, along with the <html> and <body> tags" the < br > got interpreted by the forums as a newline. This problem is still unsolved. Link to comment https://forums.phpfreaks.com/topic/102556-solved-include-image-in-mail/#findComment-525205 Share on other sites More sharing options...
Spaceman-Spiff Posted April 23, 2008 Share Posted April 23, 2008 I'm afraid I don't know much about Thunderbird. Perhaps you can try emailing your non-thunderbird mailboxes, and see how they interpret the html. If it's a Thunderbird-only problem, you may want to ask a question @ mozillazine.org forum. The code itself looks correct to me. Link to comment https://forums.phpfreaks.com/topic/102556-solved-include-image-in-mail/#findComment-525254 Share on other sites More sharing options...
IsmAvatar Posted April 23, 2008 Author Share Posted April 23, 2008 The image does not appear in Outlook Express either. Link to comment https://forums.phpfreaks.com/topic/102556-solved-include-image-in-mail/#findComment-525259 Share on other sites More sharing options...
Spaceman-Spiff Posted April 23, 2008 Share Posted April 23, 2008 I used the same script on my html file, and it works fine. The layout is a bit broken, but images work. Tested on gmail and hotmail. Can you post the contents of your email.html maybe? Link to comment https://forums.phpfreaks.com/topic/102556-solved-include-image-in-mail/#findComment-525279 Share on other sites More sharing options...
IsmAvatar Posted April 23, 2008 Author Share Posted April 23, 2008 It appears to be a problem with the image I was using. I suspect that incorrect permissions have been set to the image, so I'll contact my host to find out what's going on. Link to comment https://forums.phpfreaks.com/topic/102556-solved-include-image-in-mail/#findComment-525515 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.