在additional_header中发现多个或格式错误的换行符


Multiple or malformed newlines found in additional_header

我的mail()函数出错了。

PHP Warning: mail(): Multiple or malformed newlines found in additional_header

当我在谷歌上搜索时,我看到了一些建议。但是在additional_headers中删除多个新行不起作用。我该如何解决这个问题?

$separate =md5(time());
$el=PHP_EOL;
$headers  = "From: ".$sndr.$el;
$headers .= "Reply-To: ".$sndr.$el;
$headers .= "MIME-Version: 1.0".$el; 
$headers .= "Content-Type: multipart/mixed; boundary='"".$separate."'"".$el; 
$headers .= "Content-Transfer-Encoding: 7bit".$el;
$headers .= "This is a MIME encoded message.".$el;
$headers .= "--".$separate.$el;
$headers .= "Content-Type: text/html; charset='"iso-8859-1'"".$el;
$headers .= "Content-Transfer-Encoding: 8bit".$el;
$headers .= $message.$el;

你正在把你的信息插入你的标题:

$headers .= $message.$el;

也就是

From: someone@somewhere.com
blah: blah
Hi mom!
Content-type: blah blah

是非法邮件