Php mail() Return-Path header question

software development

#1

Hello,

In PHP it’s possible to specify a return-path header or use -fadmin@mydomain.com to make bounce message notifications come back to you.

Sadly I can not make this work here on my dreamhost server. I don’t know if this is due to DH policy or if I am failing to code it properly. Incidentally I reviewed info at php.net so I think I might be on the right track asking if this is a matter of permissions or DH policy.

Does anyone have any experience with this? My mail params are something like this:

$from=“From: Contact page <$my_email>\n”;
$hdrs=$from; $hdrs.=“Return-Path: bounce_relay@mydomain.org\n”; $hdrs .= $bcc_string;
mail($to, $subject, $msgbody, $hdrs);

I also tried it with $hdrs .= "-fadmin@mydomain.org"; but it didn’t work.

Any thoughts?

Barry


#2

Got it. I had to use “Errors-To” instead of “Return-Path” for some reason. Worked fine then.

The bounced message comes back as an attachment to an email from the webserver with a generic bounce message from DH.

Hope this helps anyone else in a similar jam.

B.


#3

Using sendmail -f should work fine if you do it properly… the resulting Return-Path header should be a valid one. I don’t know how to do it in PHP, but I know that it should work. Adding Errors-To: should work in most cases, but you should try to get it so that the envelope-sender is correct too.


#4

Instead of adding it to the headers, pass it as a 5th parameter in the mail function:

mail($to, $subject, $message, $headers, "-femail@wherever.com");

Also, you might not run into any problems with it, but the PHP manual highly recommends using \r\n in the headers, instead of just \n.

Good info here: http://www.php.net/manual/en/function.mail.php