1

我一直在处理这个线程: 从 PHP 发送 HTML 电子邮件

在过去的 5 个小时里,由于某种原因无法让我的 PHP 生成 HTML 邮件。

这是我所拥有的:

// 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);

这是我收到的:

来自技能交流网络 rnCc:技能交流网络 rn

我真的很茫然...

这是我现在拥有的:

// 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);

这是我收到的:

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>
4

3 回答 3

1

您将其命名$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";
于 2013-07-18T13:37:43.353 回答
0

也许如果你把's'放在$header的末尾?

于 2013-07-18T13:37:37.117 回答
0

PHPMailer可能是一个有用的解决方案。

于 2013-07-18T13:37:52.213 回答