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, ‘-fsomeone@somewhere.com’);

2) add a Return-Path header:

mail($to, $subject, $message, ‘Return-Path:
someone@somewhere.com\r\nFrom: someone@somewhere.com’);

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.

i.e
<?
$headers = “From: \”mydomain.com\” <webmaster@mydomain.com>\r\n” .
“Return-Path: <webmaster@mydomain.com>\r\n” .
“X-Mailer: PHP/” . phpversion();

mail(‘support@testy.com’,’test’,’test email from mydomain.com’, $headers,’-fwebmaster@mydomain.com’);

?>

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

Leave a Reply