Php mail() Return-Path header question


In PHP it’s possible to specify a return-path header or use 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 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:\n”; $hdrs .= $bcc_string;
mail($to, $subject, $msgbody, $hdrs);

I also tried it with $hdrs .= ""; but it didn’t work.

Any thoughts?


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.


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.

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

mail($to, $subject, $message, $headers, "");

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: