我搜索了很多,但找不到任何解决方案。在更改我的代码几个小时后,我尝试了 php.net 中的示例,它的行为相同。
如果我将它发送到我的 gmail 地址,一切看起来都很好,如果我将它发送到另一台服务器,它不会将其呈现为 html。我尝试了大约 8 台服务器,其中 4 台遇到了这个问题
这是代码(php示例):
// subject
$subject = 'Birthday Reminders for August';
// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>
';
// 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 .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
$headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>
这是来自 gmail 的“显示原文”(gmail 只是客户端,邮件来自 php 服务器),消息显示不正确 - html 是原始的:
Delivered-To: XXX
Received: by 10.220.35.74 with SMTP id o10csp285028vcd;
Sun, 9 Dec 2012 03:18:35 -0800 (PST)
Received: by 10.220.238.139 with SMTP id ks11mr6865773vcb.49.1355051914996;
Sun, 09 Dec 2012 03:18:34 -0800 (PST)
Received-SPF: softfail (google.com: best guess record for domain of transitioning unknown does not designate 82.80.232.249 as permitted sender) client-ip=82.80.232.249;
Received: by 10.230.67.134 with POP3 id r6mf4415353vbi.4;
Sun, 09 Dec 2012 03:18:34 -0800 (PST)
X-Gmail-Fetch-Info: gideon@example.com 5 mail.example.com 110 gideon@example.com
Received: from [82.80.232.249] by mail.example.com (ArGoSoft Mail Server .NET v.1.0.8.4) with ESMTP (EHLO web9.wishosting.net)
for <gideon@example.com>; Sun, 09 Dec 2012 13:18:02 +0200
Received: by web9.wishosting.net (Postfix, from userid 1168)
id C82D03EE2EC; Sun, 9 Dec 2012 13:18:23 +0200 (IST)
To: gideon@example.com, wez@example.com
Subject: Birthday Reminders for August
X-PHP-Script: example.com/lp/mailtest.php for 89.139.28.204
MIME-Version: 1.0
Date: Sun, 09 Dec 2012 13:18:02 +0200
Message-ID: <x0otq4xc1dcboohp09122012011802@EAWEB1>
SPF-Received: none
X-FromIP: 82.80.232.249
From: gideon@example.com
Content-type: text/html; charset=iso-8859-1
To: Mary <mary@example.com>, Kelly <kelly@example.com>
From: Birthday Reminder <birthday@example.com>
Cc: birthdayarchive@example.com
Message-Id: <20121209111823.C82D03EE2EC@web9.wishosting.net>
Date: Sun, 9 Dec 2012 13:18:23 +0200 (IST)
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</td>
</tr>
</table>
</body>
</html>