ZF-7008: Method setReturnPath() not working
Description
It seems that the method setReturnPath() is not working as it should and is not overwriting the default path.
Code example:
$reqMail = new Zend_Mail();
$reqMail->setBodyText($content);
$reqMail->setFrom("some@email.com", "Name");
$reqMail->setReturnPath('some@email.com');
$reqMail->setSubject($subject);
$reqMail->addTo('other@email.com');
$reqMail->addBcc("anemail@yahoo.com");
$reqMail->send();
The result email doesn't have the set ReturnPath.
Comments
Posted by Bogdan Martinescu (yolau) on 2009-06-13T14:45:08.000+0000
I looked into this for the past hour and I am now not sure if this is considered a bug or no.
Facts: To have a Sendmail keep the ReturnPath you have to send an additional parameter to the PHP mail function, more precise "-femail@address.com" The send() method from Zend/Mail.php doesn't do that as it calls Zend_Mail_Transport_Sendmail with no parameters to be passed to the PHP function mail(). The workaround to this is to create a Zend_Mail_Transport_Sendmail object with the proper parameter before initiating the Zend_Mail object, but this in my view will need you to set the ReturnPath twice, once in the call $tr = new Zend_Mail_Transport_Sendmail('-femail@domain.com'); and the second time with the setReturnPath("email@domain.com") method from Zend/Mail.php
A better approach would be to change line 949 from the file Zend/Mail.php from: $transport = new Zend_Mail_Transport_Sendmail(); to: if (!empty($this->_returnPath)) $transport = new Zend_Mail_Transport_Sendmail("-f" . $this->_returnPath); else $transport = new Zend_Mail_Transport_Sendmail();
This could have a side effect though...If the user runs PHP in safe_mode() and he calls the method setReturnPath from Zend/Mail.php this will ultimately result in a PHP error due to the addition parameter given to the mail() function.
I am looking for your input on this.
Posted by Benjamin Eberlei (beberlei) on 2009-09-18T02:39:35.000+0000
Personally I think setReturnPath() is just wrong on Zend_Mail, it should be a Transport option.
Posted by Satoru Yoshida (satoruyoshida) on 2009-11-14T05:15:06.000+0000
I agree with Benjamin.
I also think _returnPath parameter should be move into parameter of transport.
And it might be better to split Zend_Mail into 3 parts, for example : Zend_Mail_Sender Zend_Mail_Server (it would include transport classes) Zend_Mail_Reader (or _Receiver)
I change this issue into next major.
Posted by Benjamin Eberlei (beberlei) on 2009-11-20T03:56:03.000+0000
I don't agree with the separation of names, however we should discuss this on the 2.0 Roadmap, can you add a note on the moving of setReturnPath() to the wiki page?
http://framework.zend.com/wiki/display/…
So we dont forget it.
Posted by Satoru Yoshida (satoruyoshida) on 2009-11-27T07:07:49.000+0000
Hi, Benjamin, :D Sorry for late comment.
Yes I will add some commment the page in this weekend.
Posted by Satoru Yoshida (satoruyoshida) on 2009-12-05T20:21:56.000+0000
I will close once as document issue.
Posted by Satoru Yoshida (satoruyoshida) on 2009-12-06T00:26:41.000+0000
Soved in SVN trunk r19450