首页 > 解决方案 > 收到 mail() 多个或格式错误的换行错误

问题描述

如果没有附件,则邮件会发送成功,但是当我尝试添加附件时,它会显示mail(): Multiple or malformed newlines found in additional_header,但我只使用 1$eol表示 1PHP_EOL

$eol = PHP_EOL;

$headers = "From: ". $_POST['fullname']." <" . $from . ">" . $eol;
$headers .= 'Reply-To: <'.$from.'>' . $eol;
$headers .= "MIME-Version: 1.0" . $eol;
$headers .= "Content-Type: multipart/mixed; boundary=\"" . $separator . "\"" . $eol;
$headers .= "Content-Transfer-Encoding: 7bit" . $eol;
$headers .= "This is a MIME encoded message." . $eol;

// if attachment is exist then it'll showing an error
if ($filename) {
  $headers .= "--" . $separator . $eol;
  $headers .= "Content-Type: application/octet-stream; name=\"" . $filename . "\"" . $eol;
  $headers .= "Content-Transfer-Encoding: base64" . $eol;
  $headers .= "Content-Disposition: attachment" . $eol;
  $headers .= $content . $eol;
  $headers .= "--" . $separator . "--";
}

标签: phpemaileol

解决方案


推荐阅读