Reputation: 25
I've been working through this thread here: Sending HTML email from PHP
For the last 5 hours and for some reason cannot get my PHP to generate HTML mail.
Here's what I have:
// Construct Mail:
$message = "<html><body>Some text<br />New line<p>New para</p></body></html>";
// Send Mail:
$to = "$UserMail";
$subject = "[Skills Exchange Network] Event Created";
$header = 'MIME-Version: 1.0' . "\r\n";
$header .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$headers .= 'From: Skills Exchange Network <Mail Address is here>' . "\r\n";
$headers .= 'Cc: Skills Exchange Network <Mail Address is here>' . "\r\n";
$SendMail = mail($to,$subject,$message,$headers);
Here's what I receive:
From Skills Exchange Network rnCc: Skills Exchange Network rn
I'm truly at a loss...
Here's what I have now:
// Construct Mail:
$message = "<html><body>Some text<br />New line<p>New para</p></body></html>";
// Send Mail:
$to = "$UserMail";
$subject = "[Skills Exchange Network] Event Created";
// To send HTML mail, the Content-type header must be set
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1" . "\r\n";
// Additional Headers:
$headers .= "From: Skills Exchange Network <[email protected]>" . "\r\n";
$headers .= "Cc: Skills Exchange Network <[email protected]>" . "\r\n";
$SendMail = mail($to, $subject, $message, $headers);
And here's what I receive:
Subject: [Skills Exchange Network] Event Created
MIME-Version: 1.0rnContent-Type: text/html; charset=ISO-8859-1rnFrom: Skills Exchange Network <[email protected]>rnCc: Skills Exchange Network <[email protected]>rn
Message-Id: <[email protected]>
From: [email protected]
Date: Thu, 18 Jul 2013 10:13:08 -0500
X-Antivirus: AVG for E-mail 2013.0.3349 [3204/6500]
X-AVG-ID: ID58DD9571-36429B43
<html><body>Some text<br />New line<p>New para</p></body></html>
Upvotes: 1
Views: 965
Reputation: 30488
You are naming $headers
as $header
and because of that your content-type is not embedding.
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-Type: text/html; charset=ISO-8859-1' . "\r\n";
$headers .= 'From: Skills Exchange Network <Mail Address is here>' . "\r\n";
$headers .= 'Cc: Skills Exchange Network <Mail Address is here>' . "\r\n";
Upvotes: 1