Recently come up with new error while writing function to send email using PHP Mail() function , Windows hosting with godaddy

Warning: mail(): SMTP server response: 451 See http://pobox.com/~djb/docs/smtplf.html. in path_to_php_file on line #

So I decided to write here the solution for the next time I encounter it and I thought it might also help other people.

$to_address = "[email protected]";
$subject = "Email subject";
$message = "message  line1
message line2
message line3";
$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "To: <".$to_address.">\r\n";
$headers .= "From: Sender <".$sender_email_address.">\r\n";
mail($to_email, $subject, $message, $headers);

This works really nice with apache running with linux .. but windows system doesn’t recognize LF sequence .. so for $message we have to change it to following

$message = "message line1\r\n message line2\r\n message line3";

OR

$message = "message line1\r\n";
$message .= "message line2\r\n";
$message .= "message line3";

Happy coding !