我正在使用此处找到的php脚本:
http://css-tricks.com/2866-sending-nice-html-email-with-php/
我已将其上传到我的服务器 - 它拒绝正确发送电子邮件!
这是我在Gmail中收到的内容:(显示为原始HTML)
Content-Type: text/html; charset=ISO-8859-1
<html>
<body>
<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />
<table rules="all" style="border-color: #666;" cellpadding="10">
<tr style='background: #eee;'>
<td><strong>Name:</strong> </td>
<td>sd</td>
</tr>
<tr>
<td><strong>Email:</strong> </td>
<td>myrealemail@gmail.com.au</td>
</tr>
<tr>
<td><strong>Type of Change:</strong> </td>
<td>Change to Existing Content</td>
</tr>
<tr>
<td><strong>Urgency:</strong> </td>
<td>Super Wicked Urgent</td>
</tr>
<tr>
<td><strong>URL To Change (main):</strong> </td>
<td>http://css-tricks.com/2866-sending-nice-html-email-with-php/</td>
</tr>
<tr>
<td><strong>CURRENT Content:</strong></td>
<td>fdasgdsfg</td>
</tr>
<tr>
<td><strong>NEW Content:</strong> </td>
<td>sdfgsdgf</td>
</tr>
</table>
</body>
</html>
是否有任何服务器设置我可能需要更改???
我还在这台服务器上使用了一些似乎有同样问题的wordpress插件。
任何想法都会很棒。
更新:
**更新**
这是我点击“显示原始文件”时在Gmail中获得的内容
Delivered-To: [removed-intentionally]@gmail.com
Received: by 10.204.157.136 with SMTP id b8cs43947bkx;
Sun, 14 Aug 2011 22:29:40 -0700 (PDT)
Received: from mr.google.com ([10.236.77.232])
by 10.236.77.232 with SMTP id d68mr14702149yhe.74.1313386180151 (num_hops = 1);
Sun, 14 Aug 2011 22:29:40 -0700 (PDT)
Received: by 10.236.77.232 with SMTP id d68mr11051146yhe.74.1313386179570;
Sun, 14 Aug 2011 22:29:39 -0700 (PDT)
Return-Path: <anonymous@ub002lps00.cbr.the-server.net.au>
Received: from ironport1-mx.cbr1.mail-filtering.com.au (ironport1-mx.cbr1.mail-filtering.com.au [203.88.115.241])
by mx.google.com with ESMTP id g70si16130380yhe.152.2011.08.14.22.29.38;
Sun, 14 Aug 2011 22:29:39 -0700 (PDT)
Received-SPF: neutral (google.com: 203.88.115.241 is neither permitted nor denied by best guess record for domain of anonymous@ub002lps00.cbr.the-server.net.au) client-ip=203.88.115.241;
Authentication-Results: mx.google.com; spf=neutral (google.com: 203.88.115.241 is neither permitted nor denied by best guess record for domain of anonymous@ub002lps00.cbr.the-server.net.au) smtp.mail=anonymous@ub002lps00.cbr.the-server.net.au
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result: AqoHAHOuSE5xFATR/2dsb2JhbABBmHOPCHeEEYd0lCyfAIZHBKQJ
X-IronPort-AV: E=Sophos;i="4.67,372,1309701600";
d="scan'208,217";a="465774510"
Received: from ub002lps00.cbr.the-server.net.au ([113.20.4.209])
by ironport1-mta.cbr1.mail-filtering.com.au with ESMTP; 15 Aug 2011 15:29:03 +1000
Received: (qmail 14705 invoked by uid 10317); 15 Aug 2011 07:29:02 +0200
Date: 15 Aug 2011 07:29:02 +0200
Message-ID: <20110815052902.14702.qmail@ub002lps00.cbr.the-server.net.au>
To: [removed-intentionally]@gmail.com
Subject: Website Change Reqest
From: [removed-intentionally]@gmail.com
Reply-To: [removed-intentionally]@gmail.com
MIME-Version: 1.0
Content-Type: text/html; charset=ISO-8859-1
<html><body><img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" /><table rules="all" style="border-color: #666;" cellpadding="10"><tr style='background: #eee;'><td><strong>Name:</strong> </td><td>sd</td></tr><tr><td><strong>Email:</strong> </td><td>[removed-intentionally]@gmail.com</td></tr><tr><td><strong>Type of Change:</strong> </td><td>Change to Existing Content</td></tr><tr><td><strong>Urgency:</strong> </td><td>Super Wicked Urgent</td></tr><tr><td><strong>URL To Change (main):</strong> </td><td>http://css-tricks.com/2866-sending-nice-html-email-with-php/</td></tr><tr><td><strong>CURRENT Content:</strong> </td><td>fdasgdsfg</td></tr><tr><td><strong>NEW Content:</strong> </td><td>sdfgsdgf</td></tr></table></body></html>
答案 0 :(得分:3)
PHP手册网站(here)上有一个很好的例子,说明了如何做到这一点。尝试复制并粘贴示例4.
看起来您没有发送字符串来正确识别标题中的内容类型。也许你应该在Gmail中做一个“显示原创”并在这里发布标题,如果你无法从手册中得到它。
答案 1 :(得分:3)
出现同样的问题,发送以下标题会在一台服务器上生成HTML-Email但在另一台服务器上无效
$headers = 'From: xxx@xxx.org\r\n' .
'MIME-Version: 1.0' . "\r\n" .
'Content-type: text/html; charset=iso-8859-1' . "\r\n" .
"X-Mailer: PHP";
事实证明,\r\n
是服务器的重复换行符。因此,只需使用\ n作为换行符就可以了。
$headers = 'From: xxx@xxx.org\n' .
'MIME-Version: 1.0' . "\n" .
'Content-type: text/html; charset=iso-8859-1' . "\n" .
"X-Mailer: PHP";
答案 2 :(得分:2)
看起来MIME-Version
后的空白行表示标题已结束,因此它将Content-Type
行输出为常规文本,并将html输出后,而不是将该行作为一部分读取要知道将其余部分转换为HTML的标题。
MIME-Version: 1.0
Content-Type: text/html; charset=ISO-8859-1
<html><body>
尝试获取生成标题的内容,以删除MIME-Version
和Content-Type
之间的空白行。 (例如,你在这一行上有额外的\r\n
吗?你的代码在生成这些行的地方是什么样的?)也可以在Content-Type
和{{1}之间添加第二个空行}。
答案 3 :(得分:1)
标题问题已在php mail()函数中解决。
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $senderEmail . ' <' . $senderEmail .'>' . "
\r\n" .
'Reply-To: '. $senderEmail . "\r\n" .
'X-Mailer: PHP/' . phpversion();
答案 4 :(得分:1)
尝试一下。
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $sender . ' <' . $sender .'>' . " \r\n" .
'Reply-To: '. $sender . "\r\n" .
'X-Mailer: PHP/' . phpversion();
答案 5 :(得分:0)
在邮件标题中包含此内容
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
答案 6 :(得分:0)
尝试使用charset = UTF-8而不是ISO-8859-1 ......