:::: MENU ::::

php mail() and godaddy windows hosting !

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 = "recivers@emaild.id";
$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";


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

Happy coding !


  • Reply meetha |

    First of all thanks for the information, 50% code is working but i have still problem as ian setting html code in message some times its working and some times not, is any solution for this, i mean to say is any character limit for each $message varaiable.

    for your information, i am using godaddy windows server. Please help me thanks!

    • Reply Vinay Patel |

      Technically there is no limit for $message variable !

      Can you please provide detail where exactly you are facing problem ?

      I will be happy to help you out.


  • Reply Maru Akash |

    really innovative things for freshers and experience person,
    such a creative thought you had developed,
    i m first time visit your blog but rally interesting.
    now onward i wish to getting new idea from your references


So, what do you think ?