mail() stopped working suddenly

So my host updated PHP and all of a sudden the code I was using for a simple contact form broke. Now it will not send messages.

Facts:

[ul][li]mail([email protected],‘Simple Subject’,‘Simple Body’) returns true and arrives at [email protected].[/li]
[li]mail([email protected],‘Simple Subject’,$HTMLmessage,$headers) returns true and never arrives.[/li]
[li]Code was unchanged when it stopped working.[/li][/ul]

I’ve tried so many things and figured out that the 'From: ’ in the header requires “quotes” around the person’s name. This got me sending simple text messages (ie. $message = “WHY U NO SEND!?”), but when I include the HTML shown below, it just never arrives. I’ve read the mail() manual page up and down and gave this a solid day’s effort. Please let me know if you find anything out of the ordinary that I can fix! Thank you :slight_smile:

[php] $message = ’

Name: '.$Name.'<br><br>

Email: '.$Email.'<br><br>

Phone Number: '.$PhoneNumber.'<br><br>

Best Time to Call: '.$Time.'<br><br>

Comments:<br>'.nl2br($Comments).'<br><br>

----<br>

This is a form-generated email sent by <a href="http://www.t-s.net">T-s.net</a>.

</body></html>';

$message = stripslashes($message);
$message = wordwrap($message, 50);

echo $message;
 
$headers  = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers = 'From: "'. $Name . '" <' . $Email . '>' . "\r\n";
$headers .= 'X-Mailer: PHP/' . phpversion() . "\r\n";

if(mail('[email protected]','Contact Request!',$message,$headers)) {
  //header("Location: http://" . $_SERVER['HTTP_HOST'] . "/thanks.php");
} else {
	echo 'Dreadfully sorry, something has gone awry.' . "<br />\n";
}

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service