PHP sends mail as anonymous@servername

The from address is not enforced.  This can cause some PHP formmail script emails to be treated as spam.  Fix:

1) add a -f(sender address) parameter:

mail($to, $subject, $message, $headers, ‘’);

2) add a Return-Path header:

mail($to, $subject, $message, ‘Return-Path:\r\nFrom:’);

Qmail is *meant* to check for the from address field in Sender, From, Reply-To, Return-Path, Return-Receipt-To, Errors-To, Resent-Sender etc.
etc. *but* only Return-Path will actually set the address.

$headers = “From: \”\” <>\r\n” .
“Return-Path: <>\r\n” .
“X-Mailer: PHP/” . phpversion();

mail(‘’,’test’,’test email from’, $headers,’’);


You can leave a response, or trackback from your own site.

Leave a Reply