I have the following two tiny scripts running on an Apache/PHP server at a hosting provider.
Script 1:
PHP Code:
<?php
echo " ";
mail("non_existent_address@mydomain.com", "test email!", "This is a test.", "From: me@mydomain.com");
?>
Script 2:
PHP Code:
<?php
mail("non_existent_address@mydomain.com", "test email!", "This is a test.", "From: me@mydomain.com");
?>
- Note that we are sending email to a
non-existent email address. If we use existing addresses, the problem does not occur.
- Note that the only difference between the scripts is the removal of the echo in script 2.
Script 1 nicely returns a message saying a dead.letter was made which is lovely. Script 2 however, generates an internal server error 500. The server log will claim "malformed header from script".
Why does this happen and how to prevent the 500 error?
Thanks for any advice at all!
(Please help, as I run a forum, and when users have an email subscription to a certain thread, a bunch of mail() will be sent when someone replies in the thread. Some users may no longer have a valid email address, and the poster will get a nice Internal server 500 error rather than a normal error message when they innocently try to post a reply somewhere.