ZF-8273: setReturnPath overwrites setFrom in Zend_Mail_Protocol_Smtp

Description

$mail = new Zend_Mail(); $mail->setFrom('sender@email.com'); $mail->setReturnPath('returns@email.com'); $mail->send( .. Zend_Mail_Transport_Smtp .. );

E-mail is being sent on returns@email.com instead of sender@email.com;

Zend_Mail_Transport_Smtp, line 203: $this->_connection->mail($this->_mail->getReturnPath());

Please fix.

Comments

Hi, Marcin.

Do you mean you find mail returns back when some error is happened? Or, you find [from] address is changed on your mailer?

Hi Satoru,

I mean that e-mail is sent from "returns@email.com" instead of "sender@email.com". I understand that e-mail should be sent from "sender@email.com" with Return-Path header set to "returns@email.com" - in case of error. Do I understand incorrectly?

Cheers, Marcin

I change code in SVN r18988 (trunk), 18989 (1.9 branch) .

You are correct, Marcin. For your purpose, getReturnPath() should be replaced with getFrom().

And I have a sadly information I must notice you :-( As it is pointed out in ZF-7008, setReturnPath can not work fine now.

The function is under consideration how to fix.

Hi Satoru, hi Marcin,

unfortunately this is broken now. The Return-Path has to be used as MAIL FROM: in the SMTP transport. So please undo your replacement of getReturnPath() with getFrom(), because it was working correctly before.

Thanks, Janis

Please present some code to reproduce, and describe the problem with that code. Thanks.

Zend_Mail_Transport_Smtp, line 203: was (correct): $this->_connection->mail($this->_mail->getReturnPath()); is now (incorrect): $this->_connection->mail($this->_mail->getFrom());

This results in always using the "Body-From" (From:-Header), as "Envelope-From" ("MAIL FROM:" SMTP command) and removes the possibility to use different Envelope-From and Body-From Addresses.

See RFC 2821 and http://en.wikipedia.org/wiki/Bounce_address for reference.

Ouch. Will fix tonight.

bump

It's still not fixed in trunk - and it breaks our mail code ;-)

ZF-8988 was opened because this was not actually a bug and the "solution" broke Zend_Mail to not be compliant with the RFC with the SMTP transport.

Closing this issue to avoid confusion -- see ZF-8988 for the fix.