we upgraded our version of PHP and are now getting the error " Warning: mail(): Multiple or malformed newlines found in additional_header".
I've created experimenting with different things but haven't gotten anything to work. I apologize as I'm not very familiar with how all of this works, so please bear with me.
The objective (which worked in earlier versions) is to send an HTML based message (has ,
tags, etc) that includes a PDF attachment that exists on our server.
If you can give me specific adjustments, I'd appreciate it greatly!
$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;
}
because of https://bugs.php.net/bug.php?id=68776 multiple linebreaks are not allowed anymore (or at the moment?). Try to switch to PEAR Mailer, PHPMailer or something else.
Multiple linebreaks "\n\n"
are needed to send php mails with attachments with mail()...