Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 2.0.0

Request #5017 Set envelope sender
Submitted: 2005-08-06 18:26 UTC
From: gsstark at mit dot edu Assigned: chagenbu
Status: Closed Package: Mail
PHP Version: Irrelevant OS:
Roadmaps: (Not assigned)    
Subscription  


 [2005-08-06 18:26 UTC] gsstark at mit dot edu
Description: ------------ When sending email there are three pieces of data, the envelope sender, the envelope recipient and the data of the message including headers and body. The interface currently provides a way to set the recipients and the body of the message but no way to set the envelope sender. There are many reasons to want to set the envelope sender, but the main one that comes to mind is to generate VERP-style addresses for bounce processing. But regardless, it just seems incomplete to only provide access to two of the three parts of a message.

Comments

 [2005-08-09 04:57 UTC] jon
We actually *only* set the envelope sender. Maybe it's non-obvious, but the Mail package uses the value from the From: header (which you specify) as the sender value. If you don't specify a From: header, the Mail package should be throwing an error.
 [2005-08-09 12:50 UTC] gsstark at mit dot edu
That's my complaint. What if I don't want it to be the same as the From header?
 [2005-08-25 04:57 UTC] jon
I suppose there are cased where that's useful, but mismatching those fields can also make the resulting message appear suspect (e.g., a forged From: address). I'll consider adding another parameter to the send() method which would allow the sender to be specified explicitly instead of relying on the existence of the From: header.
 [2005-09-01 09:46 UTC] neuhauser+pear dot php dot net at sigpipe dot cz
Jon, "From: " / "MAIL FROM: <>" mismatch is what makes email bounces, mailing lists, and other things, work at all. Please do add the feature. On a related note, $recipients (1st param) in Mail::send is busted: it bogusly qualifies the addresses.
 [2005-09-13 07:07 UTC] jon
I think I'm going to postpone any work on this issue until the 1.2.0 release. I want to release 1.1.9 with some bug fixes first, and I don't want any potential complications with the feature requested here to hold up that release.
 [2006-02-16 08:31 UTC] shot at hot dot pl
‘I suppose there are cased where that’s useful, but mismatching those fields can also make the resulting message appear suspect (e.g., a forged From: address).’ I’d say one of the quite useful cases is putting anything beyond the bare email address (like, say, the full name of the recipient). MAIL FROM:<> cannot contain anything beyond the clear address, and the fact that MAIL FROM:<"Piotr Szotkowski" <shot@hot.pl>> works in Postfix is actually Postfix being nice; try the same with Courier and you’ll get a syntax error.
 [2006-02-16 11:42 UTC] shot at hot dot pl
From reading the source, it seems setting the Return-Path header takes care of the MAIL FROM:<> problem (and it does seem to work). So it's actually possible to set the MAIL FROM:<> to a different value than From: header, by setting $headers['Return-Path'].
 [2006-02-18 08:06 UTC] pc at hillside dot co dot uk
Can the sendmail interface be made to have the same behaviour as the SMTP interface - ie taking $from from Return-Path? For reasons why this is not Irrelevant and why I need to set the Envelope different from the From - see http:// www.openspf.org/webgenerated.html
 [2007-02-01 19:17 UTC] andyNOOSSPPAM at paradigm-reborn dot com (Andy Fowler)
I can confirm that setting the Return-Path header will set the MAIL FROM: <> envelope when using the SMTP transport. Another related note is that the $verp settings are dependent on the MTA, and that Exim (as of 4.63) doesn't support them. I got the impression that setting $verp would work it's own pre-MTA magic. Just a note to save some time for others.
 [2007-02-18 06:02 UTC] tms at infamous dot net (Tom Swiss)
It's great that the Return-Path magic works. It's highly suboptimal that it's not documented, that I only found out about thiss functionality through desperate and frantic Googling. IMHO this information needs to be in the Mail::send() page.
 [2007-07-08 03:37 UTC] chagenbu (Chuck Hagenbuch)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better. The sendmail driver now has the same Return-Path behavior, and the documentation has been adjusted.
 [2008-12-03 11:09 UTC] iphitos (Michael Werner)
Anyone who is in need of the -f parameter will be helped here... simply edit the Mail/sendmail.php in the PEAR Mail package changing this line: $mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . " -f$from -- $recipients", 'w'); to this: $s_from = strpos($this->sendmail_args, "-f") === false ? " -f".$from : ""; $mail = @popen($this->sendmail_path . (!empty($this->sendmail_args) ? ' ' . $this->sendmail_args : '') . $s_from . " -- $recipients", 'w'); After that, when creating your class instance, simply pass the paramater along with or as your sendmail_args (defaults to "-i") e.g.: $mail =& Mail::factory('sendmail', array('sendmail_args' => '-i -fxyz@yourdomain.com')); ***** Hope this helps anyone who is in need of the -f parameter :)