PHP Mail - Multiple or Incorrect Linefeeds Detected

we updated our version of PHP and now we get the error message "Warning: mail (): multiple or incorrect newline characters found in extra_header".

I created experiments with different things, but did not get anything to work. I apologize because I am not very familiar with how this all works, so please bear with me.

The goal (which worked in earlier versions) is to send an HTML-based message (yes, tags, etc.), which includes a PDF attachment existing on our server.

If you can give me some adjustments, I would really appreciate it!

$sFrom = "[Company Name] <[Our Email]>";
$sReplyTo = "[Our Email]";
$sParams = "-f [Our Email]";
$attachment = chunk_split(base64_encode(file_get_contents($sPath)));
$uid = md5(uniqid(time()));

$sHeaders = "From: ".$sFrom."\n".
            "Reply-To: ".$sReplyTo."\n".
            "MIME-Version: 1.0\n".
            "Content-Type: multipart/mixed; boundary=\"".$uid."\"\n\n".
            "This is a multi-part message in MIME format.\n".
            "--".$uid."\n".
            "Content-Type: text/html; charset='iso-8859-1'\n".
            "Content-Transfer-Encoding: 7bit\n\n".
            $sMessage."\n\n".
            "--".$uid."\n".
            "Content-Type: application/pdf; name=\"".$sFileName."\"\n".
            "Content-Transfer-Encoding: base64\n".
            "Content-Disposition: attachment; filename=\"".$sFileName."\"\n\n".
            $attachment."\n\n".
            "--".$uid."--";    
if (!mail($sTo, $sSubject, "", $sHeaders, $sParams)) {
    $bError = true;
}
+4
source share
4

- https://bugs.php.net/bug.php?id=68776 ( ?). PEAR Mailer, PHPMailer - .

php- ()... "\n\n"

0

\\\n \n.

0

1) $sMessage. , ($ sTo, $sSubject).

2) , if (! mail ($ sTo, $sSubject, "", $sHeaders, $sParams)) if (! mail ($ sTo, $sSubject, $sMessage, $sHeaders, $sParams))

3) "multipart/mixed"

,

4) " MIME" :

$sFrom = "me@aju.ro";
$sReplyTo = "me@aju.ro";
$sParams = "-f me@aju.ro";
$attachment = chunk_split(base64_encode(file_get_contents($sPath)));
$uid = md5(uniqid(time()));

$sHeaders = "From: ".$sFrom."\n".
            "Reply-To: ".$sReplyTo."\n".
            "MIME-Version: 1.0\n".
            "Content-Type: multipart/mixed; boundary=\"".$uid."\"\n".
            "--".$uid."\n".
            "Content-Type: text/html; charset='iso-8859-1'\n".
            "Content-Transfer-Encoding: 7bit\n\n".
$sMessage="\n\n".
            "--".$uid."\n".
            "Content-Type: application/pdf; name=\"".$sFileName."\"\n".
            "Content-Transfer-Encoding: base64\n".
            "Content-Disposition: attachment; filename=\"".$sFileName."\"\n\n".
            $attachment."\n\n".
            "--".$uid."--";    
if (!mail($sReplyTo, $sSubject, $sMessage, $sHeaders, $sParams)) {
    $bError = true;
}
0

php. PHP mail() , .

_headers. " ":\r\r,\r\0,\r\n\r\n,\n\n,\n\0.

0

All Articles