gergy008 Posted February 13, 2011 Share Posted February 13, 2011 I'm having trouble with this emailing script. As you can see it clearly sets the contect typw to text/html but when you read the email it's not in HTML like intended $to=$email; $subject='Activate your account.'; $message=" <html> <head> <title>Activate your account that doesn't show in HTML damn it -.-</title> </head> <body> <p>Nothing here.</p> </body> </html> "; // To send HTML mail, the Content-type header must be PROPERLY set $headers = 'MIME-Version: 1.0' . '\r\n'; $headers .= 'Content-type: text/html; charset=iso-8859-1' . '\r\n'; // Additional headers $headers .= 'To: $fname <$email>' . '\r\n'; $headers .= 'From: **************' . '\r\n'; $headers .= 'Reply-To: ******************' . '\r\n'; $headers .= 'X-Mailer: PHP/' . phpversion(); // Mail it $mail=mail($to, $subject, $message, $headers); Can someone help me solve why it's sending as plain text and not HTML this is getting annoying Thanks in advance, Quote Link to comment Share on other sites More sharing options...
BlueSkyIS Posted February 13, 2011 Share Posted February 13, 2011 i don't like messing with all those details of mime types, etc. i suggest that you use an existing email class to make things simpler. i use rmail. if you follow the example scripts included in the download, it is very easy to set HTML, add attachments, etc. http://www.phpguru.org/downloads/Rmail/Rmail%20for%20PHP/ I understand that your question relates to HTML and not attachments, but rmail does a great job of making HTML emails simple whether you add attachments or not. Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted February 13, 2011 Share Posted February 13, 2011 The reason the OPs code doesn't work is probably that the EOL characters are enclosed in single quotes, not double quotes. This is causing the email headers to be invalid. Do this instead: <?php $to=$email; $subject='Activate your account.'; $message=" <html> <head> <title>Activate your account that doesn't show in HTML damn it -.-</title> </head> <body> <p>Nothing here.</p> </body> </html> "; // To send HTML mail, the Content-type header must be PROPERLY set $headers = "MIME-Version: 1.0\r\n"; $headers .= "Content-type: text/html; charset=iso-8859-1\r\n"; // Additional headers $headers .= "To: $fname <$email>\r\n"; $headers .= "From: **************\r\n"; $headers .= "Reply-To: ******************\r\n"; $headers .= 'X-Mailer: PHP/' . phpversion(); // Mail it $mail=mail($to, $subject, $message, $headers); ?> Ken 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.