Firefox PHP

Return-Path mail header

Posted by frankbiff 
Return-Path mail header
December 06, 2006 09:33PM
You might need to add a return-path mail header to trouble shoot bounced emails. If you find a lot of pending approvals that are old, some might be there because the user never received the activation email. There could be a few reasons for this. In my case the outgoing mail server did not have reverse DNS lookup, so some ISPs rejected the emails. The hosting folks fixed the problem.

The mail failure notice is sent to the address in the mails return-path header. Have phorum send you an email and look at the headers (email reader should have a view headers all someplace). If you have access to the indicated email no problem. But you might be on a shared server and the return path might be set to something like root .

If you think you have bounced email and you cannot read or get the failure notices you need to set the return path to some address that you have access to like the phorum email address set in the control panel.

First save a copy of email_functions.php in case you mess up, then do the following to email_functions.php:


 $mailheader ="Content-Type: text/plain; charset={$PHORUM["DATA"]["CHARSET"]}\nContent-Transfer-Encoding:
 {$PHORUM["DATA"]["MAILENCODING"]}\nX-Mailer: $mailer$msgid\n";


 $mailheader ="Content-Type: text/plain; charset={$PHORUM["DATA"]["CHARSET"]}\nContent-Transfer-Encoding:
 {$PHORUM["DATA"]["MAILENCODING"]}\nX-Mailer: $mailer$msgid\nReturn-Path: $from_address\n";

Return-Path:$from_address\n is added at the end of the statement.

This will set the retrun path to the phorum email address, you could enter another address directly if you want and know what you are doing.

Failure notices should now go to this address and you can determine what the problem is.

There does not seem to be a nice whay to write a module to do this, you could use the phorum_hook("send_mail"). You would have to have the module set everything up and call the mail function then return 0, when $send_messages is tested the mail email function will not send the mail, not sure if this would produce an error message.



I just found that this reduces the spam ranking of the email that some spam filters issue, probably because the return path email address is now the same as the from address.

Edited 2 time(s). Last edit at 12/06/2006 09:39PM by frankbiff.
Re: Return-Path mail header
December 08, 2006 07:44AM
Thanks for that Frank however it seems my server likes to override the setting. A search around seems to point to PHP's fifth mail paramenter, where would I set this?

[edited bit] ok, i guess it's the one below your suggested change:
mail($address, $mailsubject, $mailmessage, $mailheader."From: $from_address");

I think I may have to go down the manual setting route.



Edited 1 time(s). Last edit at 12/08/2006 08:04AM by MarkFresh.
Re: Return-Path mail header
December 08, 2006 11:24AM
I think that the Return-Path header is usually set by the last system that actually delivers the mail to the users system. I would expect some might override.

One thing I noticed that might be the problem. The string in $from_address is set to a complete address with a quoted name followed by the email between brackets. Your outgoing mail server might not like that for return-path but it works on mine, Qmail. You might want to try this, (I have not tested it)

$return_address = "<".$PHORUM['system_email_from_address'].">"; 

$mailheader ="Content-Type: text/plain; charset={$PHORUM["DATA"]["CHARSET"]}\nContent-Transfer-Encoding:
 {$PHORUM["DATA"]["MAILENCODING"]}\nX-Mailer: $mailer$msgid\nReturn-Path: $return_address\n";

The end of the statement has been changed to: Return-Path: $return_address\n"

Don't know if the "< >"'s are absolutely necessary but I always see return-path addresses with them.

Sorry, only registered users may post in this forum.

Click here to login