php mail() issues?

See attached.

This function has been used since Dec. 31, 2014 (date last changed) until last Friday. It has been executed hundreds of times successfully.

Starting then, it produces the error message "mail send ... ERROR!"

In the attached version, I added the php error reporting at the top,

It now shows:

Warning: mail(): Multiple or malformed newlines found in additional_header in /home/fwsprinkler/public_html/fwsprinklercdb.info/mail_attachment.php on line 28
kk =
mail send ... ERROR!

Is it possible that the host upgraded the version of php & the newer version has some issue with this?

<?php
function mail_attachment($filename, $path, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {
	error_reporting(E_ALL);
	ini_set('display_errors', 1);
    $file = $path.$filename;
    $file_size = filesize($file);
    $handle = fopen($file, "r");
    $content = fread($handle, $file_size);
    fclose($handle);
    $content = chunk_split(base64_encode($content));
    $uid = md5(uniqid(time()));
    $name = basename($file);
    $header = "From: ".$from_name." <".$from_mail.">\r\n";
    $header .= "Reply-To: ".$replyto."\r\n";
    $header .= "MIME-Version: 1.0\r\n";
    $header .= "Content-Type: multipart/mixed; boundary=\"".$uid."\"\r\n\r\n";
    $header .= "This is a multi-part message in MIME format.\r\n";
    $header .= "--".$uid."\r\n";
    $header .= "Content-type:text/plain; charset=iso-8859-1\r\n";
    $header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
    $header .= $message."\r\n\r\n";
    $header .= "--".$uid."\r\n";
    $header .= "Content-Type: application/octet-stream; name=\"".$filename."\"\r\n"; // use different content types here
    $header .= "Content-Transfer-Encoding: base64\r\n";
    $header .= "Content-Disposition: attachment; filename=\"".$filename."\"\r\n\r\n";
    $header .= $content."\r\n\r\n";
    $header .= "--".$uid."--";
	$kk = mail($mailto, $subject, "", $header);
	echo "kk = " . $kk . "<br>";
    if ($kk) {
        echo "mail send ... OK"; // or use booleans here
    } else {
        echo "mail send ... ERROR!";
    }
}
?>

Open in new window

mail-attachment.php
Richard KortsBusiness Owner / Chief DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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.

Ray PaseurCommented:
What version of PHP was running before last Friday?  What version is running now?  It looks like this bug may have been fixed.
https://bugs.php.net/bug.php?id=68776

If that turns out to be the case, there may be a useful solution here:
http://mindofdes.blogspot.co.uk/2015/07/error-with-php-mail-multiple-or.html

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
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
Ray,

This is at GoDaddy, your favorite.

The current version is 5.4. I don't know if I can find out what it was last Friday.

I didn't see what version was being addressed in https://bugs.php.net/bug.php?id=68776
Richard KortsBusiness Owner / Chief DeveloperAuthor Commented:
I think I will try the fix suggested at the other link. Seems odd, but if it works............

Thanks
Ray PaseurCommented:
Yeah, it's easy to test their suggestion!
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
PHP

From novice to tech pro — start learning today.