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

Hello Expert,

I'm getting this error:

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

from my old mail script (beneath) .

$pdfdoc = $pdf->Output("", "S");
		$attachment = chunk_split(base64_encode($pdfdoc));

		// a random hash will be necessary to send mixed content
		$separator = md5(time());
		// carriage return type (we use a PHP end of line constant)
		$eol = PHP_EOL;

		$message = "<p>Geachte relatie,<br><br>Als bijlage ontvangt u uw factuur voor uw sponsorcontract voor het seizoen 2014/2015.<br><BR>Voor vragen en/of opmerkingen over de factuur, uw lopende sponsorcontract en de mogelijkheden die ZFC Zuidlaren u kan bieden kunt u ons bereiken via<BR><BR>Uiteraard zijn wij u ook dit jaar weer dankbaar voor uw financiële steun.<BR><BR>Met vriendelijke groet,<BR><BR></p>";

		// main header (multipart mandatory)
		$from = "";
		$headers  = "From: ".$from.$eol;
		$headers .= "MIME-Version: 1.0".$eol; 
		$headers .= "Content-Type: multipart/mixed; boundary=\"".$separator."\"".$eol.$eol; 
		$headers .= "Content-Transfer-Encoding: 7bit".$eol;
		$headers .= "This is a MIME encoded message.".$eol.$eol;

		// message
		$headers .= "--".$separator.$eol;
		$headers .= "Content-Type: text/html; charset=\"iso-8859-1\"".$eol;
		$headers .= "Content-Transfer-Encoding: 8bit".$eol.$eol;
		$headers .= $message.$eol.$eol;

		// attachment
		$headers .= "--".$separator.$eol;
		$headers .= "Content-Type: application/octet-stream; name=\"".$bestandsnaam."\"".$eol; 
		$headers .= "Content-Transfer-Encoding: base64".$eol;
		$headers .= "Content-Disposition: attachment".$eol.$eol;
		$headers .= $attachment.$eol.$eol;
		$headers .= "--".$separator."--";
		$subject = "Factuur Sponsoring ZFC Zuidlaren";

		// send message
		mail($email, $subject, "", $headers);

Open in new window

Can someone explain what should be changed to make it work again?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Dave BaldwinFixer of ProblemsCommented:
Email headers require '\r\n'.  PHP_EOL is determined by the OS you are running on.  It is '\r\n' only if you are on Windows.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
SteynskAuthor Commented:
Dave BaldwinFixer of ProblemsCommented:
You're welcome.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.