如果没有附件,那么电子邮件将成功发送,但当我尝试添加附件时,它会显示mail(): Multiple or malformed newlines found in additional_header
,但我只使用1 $eol
,这意味着1 PHP_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 . "--";
}