NathanLedet Posted June 30, 2008 Share Posted June 30, 2008 I have a script that $to = [email protected]; $subject = "subject goes here"; $body = "<p style=color: #0000ff;>text goes here</p>"; $headers = "From: Nate L <[email protected]>\r\n" . "X-Mailer: php"; $headers .= "Content-type: text/html\r\n"; if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent</p>"); } else { echo("<p>Message delivery failed...</p>"); } When the e-mails come in, the HTML is displayed, but not rendered out. I would appreciate some help with this Link to comment https://forums.phpfreaks.com/topic/112648-solved-php-generates-html-email/ Share on other sites More sharing options...
rhodesa Posted June 30, 2008 Share Posted June 30, 2008 first thing add a \r\n at the end of this line (i added it here): $headers = "From: Nate L <[email protected]>\r\n" . "X-Mailer: php\r\n"; but you will find a lot of email clients don't honor CSS attributes...you have to use "old school" styling: $body = "<p><font color=\"#0000ff\">text goes here</font></p>"; Link to comment https://forums.phpfreaks.com/topic/112648-solved-php-generates-html-email/#findComment-578493 Share on other sites More sharing options...
br0ken Posted June 30, 2008 Share Posted June 30, 2008 By displayed but not rendered do you mean you wish to see the tags rather than them actually being used to style the information? If so use... <?php echo htmlspecialchars($var); ?> Link to comment https://forums.phpfreaks.com/topic/112648-solved-php-generates-html-email/#findComment-578495 Share on other sites More sharing options...
rhodesa Posted June 30, 2008 Share Posted June 30, 2008 p.s. - what email client are you using to receive emails? Link to comment https://forums.phpfreaks.com/topic/112648-solved-php-generates-html-email/#findComment-578501 Share on other sites More sharing options...
NathanLedet Posted June 30, 2008 Author Share Posted June 30, 2008 when the e-mails are coming in, you can see the <p></p> tags..none of the HTML is rendered. I actually want the text to render out in blue. I'm testing on a few e-mails...my yahoo account is one, the other one is my mac Mail app. Link to comment https://forums.phpfreaks.com/topic/112648-solved-php-generates-html-email/#findComment-578529 Share on other sites More sharing options...
rhodesa Posted June 30, 2008 Share Posted June 30, 2008 first thing add a \r\n at the end of this line (i added it here): $headers = "From: Nate L <[email protected]>\r\n" . "X-Mailer: php\r\n"; but you will find a lot of email clients don't honor CSS attributes...you have to use "old school" styling: $body = "<p><font color=\"#0000ff\">text goes here</font></p>"; and you've made these changes from above? Link to comment https://forums.phpfreaks.com/topic/112648-solved-php-generates-html-email/#findComment-578537 Share on other sites More sharing options...
NathanLedet Posted June 30, 2008 Author Share Posted June 30, 2008 I replied before making the changes.... I just made them and it works! Thanks for your help!! Link to comment https://forums.phpfreaks.com/topic/112648-solved-php-generates-html-email/#findComment-578551 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.