我正在使用 PHPmail()
发送带有 CSV 文件附件的电子邮件。我的问题是服务器将其中一些(实际上是大多数)邮件置于隔离区。根据日志,原因是:
mail.info:Sep 9 21:34:08 mailout4 amavis[18812]: (18812-05-2) Passed BAD-HEADER-2 {RelayedOpenRelay,Quarantined}, [xxx.xxx.xxx.xxx] <xyz@ws15.surf-town.net> -> <xyz@xyz.com>, mail_id: skJU2BMP1ssu, Hits: 1.117, size: 5145, queued_as: BB1DE33018, 2571 ms
BAD-HEADER-2 refers to: CC_BADH.',2', "id=%n - BAD HEADER: nonencoded 8-bit character",
所以我认为这是由于 CSV 文件数据中的一些特殊字符而发生的?
发送邮件的代码如下所示(还有更多代码,但这会显示邮件标题等)。
//create attachment from array of data $csvdata
$attachment = chunk_split(base64_encode(create_csv_string($csvData,$filename)));
// Make the body of the message
$body = "--$multipartSep\r\n"
. "Content-Type: text/plain; charset=utf-8; format=flowed\r\n"
. "Content-Transfer-Encoding: 7bit\r\n"
. "\r\n"
. "$body\r\n"
. "--$multipartSep\r\n"
. "Content-Type: text/csv\r\n"
. "Content-Transfer-Encoding: base64\r\n"
. "Content-Disposition: attachment; filename=\"$filename\"\r\n"
. "\r\n"
. "$attachment\r\n"
. "--$multipartSep--";
$subject .= ' (' . date('Y-m-d H:i:s') . ')';
$headers = array(
"From: $from",
"Reply-To: $from",
"Content-Type: multipart/mixed; boundary=\"$multipartSep\""
);
$recievers = explode(','.$to);
foreach ($recievers as $reciever) {
mail($reciever, $subject, $body, implode("\r\n", $headers));
}
你们中有人遇到过这个问题吗?
关于不需要更改服务器设置的修复的任何想法?