[英]Formatting HTML with PHP Mail
I've been working through this thread here: Sending HTML email from PHP 我一直在这里处理此线程: 从PHP发送HTML电子邮件
For the last 5 hours and for some reason cannot get my PHP to generate HTML mail. 在过去的5个小时里,由于某种原因,我的PHP无法生成HTML邮件。
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
来自技能交流网络rnCc:技能交流网络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 <info@skillsexchangenetwork.net>" . "\r\n";
$headers .= "Cc: Skills Exchange Network <info@skillsexchangenetwork.net>" . "\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 <info@skillsexchangenetwork.net>rnCc: Skills Exchange Network <info@skillsexchangenetwork.net>rn
Message-Id: <E1UzptE-0003e1-Fs@wdt.webserversystems.com>
From: skillsex@wdt.webserversystems.com
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>
You are naming $headers
as $header
and because of that your content-type is not embedding. 您将
$headers
命名为$header
,因此您的内容类型未嵌入。
$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";
也许是否因此将$放在$ header的末尾?
PHPMailer可能是一个有用的解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.