bfinke Posted December 30, 2008 Share Posted December 30, 2008 I've been working on this for hours and its driving me insane. <?php $email = '[email protected]'; $subject = "Test"; $message = "<h2>Hello</h2><p>Second line here</p>"; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: [email protected]' . "\r\n" . 'Reply-To: [email protected]' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); $checker = mail($email, $subject, $message, $headers); ?> After sending the email, the headers show up in the body of the email and its all just text, no html like I'm going for. This is the email: Content-type: text/html; charset=iso-8859-1 From: [email protected] Reply-To: [email protected] X-Mailer: PHP/4.3.9 <h2>EHLLO</h2><p>this should be on a new line and this is </p> Any help is appreciated very much! Quote Link to comment https://forums.phpfreaks.com/topic/138936-headers-in-email-body/ Share on other sites More sharing options...
iarp Posted December 30, 2008 Share Posted December 30, 2008 I'm unsure whats wrong with yours, i use the following. $HTML = your message content/body. $headers = "From: $from\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $boundary = uniqid("HTMLEMAIL"); $headers .= "Content-Type: multipart/alternative;". "boundary = $boundary\r\n\r\n"; $headers .= "This is a MIME encoded message.\r\n\r\n"; $headers .= "--$boundary\r\n". "Content-Type: text/plain; charset=ISO-8859-1\r\n". "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode(strip_tags($HTML))); $headers .= "--$boundary\r\n". "Content-Type: text/html; charset=ISO-8859-1\r\n". "Content-Transfer-Encoding: base64\r\n\r\n"; $headers .= chunk_split(base64_encode($HTML)); Quote Link to comment https://forums.phpfreaks.com/topic/138936-headers-in-email-body/#findComment-726628 Share on other sites More sharing options...
MatthewJ Posted December 30, 2008 Share Posted December 30, 2008 yeah, I have never seen the headers come through... but are you sure you have your mail client set to receive html email? Quote Link to comment https://forums.phpfreaks.com/topic/138936-headers-in-email-body/#findComment-726635 Share on other sites More sharing options...
bfinke Posted December 31, 2008 Author Share Posted December 31, 2008 I find it curious too, I changed it too $subject = "Your spring textbooks"; $message = "<h2>This is right</h2><p>Yes this is right! $mascot_temp $firstname_temp $userid_temp</p>"; $headers = 'From: [email protected]' . "\r\n"; $headers .= "Content-type: text/html"; And it's working. But still doesn't seem right to me. Quote Link to comment https://forums.phpfreaks.com/topic/138936-headers-in-email-body/#findComment-726656 Share on other sites More sharing options...
Sesquipedalian Posted December 31, 2008 Share Posted December 31, 2008 Something is wrong with your site, I tested out your code and it worked perfectly for me. Quote Link to comment https://forums.phpfreaks.com/topic/138936-headers-in-email-body/#findComment-726666 Share on other sites More sharing options...
chronister Posted December 31, 2008 Share Posted December 31, 2008 I placed the code on my server, and sent the mail to my email address. It comes back as HTML. I attached a screenshot of it in my email client.... (gmail). nate [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/138936-headers-in-email-body/#findComment-726705 Share on other sites More sharing options...
bfinke Posted December 31, 2008 Author Share Posted December 31, 2008 Thanks all for your help. Any thoughts on what could be wrong with my server? I called Lunarpages and told them something was up and, of course, they were helpless. Quote Link to comment https://forums.phpfreaks.com/topic/138936-headers-in-email-body/#findComment-726717 Share on other sites More sharing options...
chronister Posted December 31, 2008 Share Posted December 31, 2008 What email client are you using to receive the emai? It seems like it is more your email client rather than the server. Nate Quote Link to comment https://forums.phpfreaks.com/topic/138936-headers-in-email-body/#findComment-726754 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.