If you set the Return-Path header in code it will be discarded in favor of the from address. Under a range of circumstances it is important to be able to set the Return-Path in code - for example when running a mailing list, or processing bounced email.
function my_module_mail_alter(&$message) {
// Will be ignored.
$message['headers']['Return-Path'] = 'return-path@example.com'
}
This is an example of what you have to do with PHPMailer in order to set a Return-Path header such that it is different from the Reply-To or From headers:
$mail->Sender = $return_path_email;
$mail->From = $from_email;
$mail->FromName = $from_name;
$mail->AddAddress($to_email);
Comments
Comment #1
exratione commentedPatch attached.
Comment #2
simon georges commentedChanging status, as there is a patch.
Comment #3
wundo commentedCould you please re-roll the patch?
Comment #4
simon georges commentedPatch re-rolled. Caution: no test done.
Comment #5
jonhattanIt works!
Comment #5.0
jonhattanMore info.
Comment #6
josesanmartin commentedThis has been commited to dev. Thank you exratione and Simeon, have a happy new year! :)
Comment #8
nathaniel commentedHello, I just want to note that this bit of code sets my Sender to blank if the Return-Path header is blank and causes email to fail. Had to comment it out for now. I think the empty Return-Path header is coming from the mimemail module.
Comment #9
Anders Kallin commentedI think that this fix is incompatible with this patch, no?
https://drupal.org/node/1686588#comment-7468620
And why set 'Sender' when we really want to set 'Return-Path'?
Oh,it's the phpmailer implementation that unfortunately uses them interchangeably.