Issue Type: Docs: Improvement Created: 2009-06-13T11:02:01.000+0000 Last Updated: 2010-01-30T00:30:05.000+0000 Status: Resolved Fix version(s): - 1.10.0 (27/Jan/10)
Reporter: Bogdan Martinescu (yolau) Assignee: Satoru Yoshida (satoruyoshida) Tags: - Zend_Mail
Related issues: - ZF-8988
It seems that the method setReturnPath() is not working as it should and is not overwriting the default path.
<pre class="highlight"> $reqMail = new Zend_Mail(); $reqMail->setBodyText($content); $reqMail->setFrom("email@example.com", "Name"); $reqMail->setReturnPath('firstname.lastname@example.org'); $reqMail->setSubject($subject); $reqMail->addTo('email@example.com'); $reqMail->addBcc("firstname.lastname@example.org"); $reqMail->send();
The result email doesn't have the set ReturnPath.
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 "-email@example.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('-firstname.lastname@example.org'); and the second time with the setReturnPath("email@example.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?
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
Have you found an issue?
See the Overview section for more details.