【发布时间】:2014-09-15 06:53:23
【问题描述】:
我已经编写了一个使用 PHP mail() 函数发送邮件的代码
$message = "
<html>
<head>
<title>TITLE</title>
</head>
<body>
<p>Customer ".$customerName." with id ".$customerId." wishes to place order for the following products that are currently note available in stock</p>
<table>
<tr>
<th align='center'>Product Name</th>
<th align='center'>Product Id</th>
<th align='center'>Product Part Number</th>
<th align='center'>Quantity</th>
</tr>"
.$content.
"
</table>
</body>
</html>
";
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=UTF-8" . "\r\n";
// More headers
$headers .= 'From: '.$customerEmail.'' . "\r\n";
mail($to,$subject,$message,$headers);
邮件对我来说工作正常,但对于客户来说,它看起来像这样
From:
Sent: None
To: orders@xxxxx.com
Subject: SUBJECT
Content-type:text/html;charset=UTF-8
From: xxxx@xxxx.com
Message-Id: <20140908144611.165ACC36BC@SV08.xxxxxx.com>
Date: Mon, 8 Sep 2014 17:46:11 +0300 (AST)
X-Nonspam: None
X-Antivirus: avast! (VPS xxx-0, 09/09/2014), Inbound message
X-Antivirus-Status: Clean
<html>
<head>
<title>TITLE</title>
</head>
<body>
<p>Customer XXXX with id 3
wishes to place order for the following products that are currently not
available in stock</p>
<table>
<tr>
<th align='center'>Product Name</th>
<th align='center'>Product Id</th>
<th align='center'>Product Part Number</th>
<th align='center'>Quantity</th>
</tr><tr><td
align='center'>SCREW;BHHS;3/8-16 X .75</td><td align='center'>3237<td
align='center'>35059</td><td align='center'>6</td></tr>
</table>
</body>
</html>
我不明白为什么它对我们的测试有效,但对客户无效。我使用我的 gmail 帐户进行了测试,当客户在其公司域上使用他的邮件 ID 时,它显示良好。
【问题讨论】:
-
我感觉,设置的问题可能是客户端没有启用邮件的html内容
-
只需重启你的测试服务器
-
如何为客户端 Ram sharma 启用 html 内容??
-
我觉得你需要把双引号(")换成单引号(')...