Jump to content

[SOLVED] PHP generates HTML email


NathanLedet

Recommended Posts

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

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>";

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.