--- tests/Zend/Mail/AllTests.php (revision 23299) +++ tests/Zend/Mail/AllTests.php (working copy) @@ -38,6 +38,7 @@ require_once 'Zend/Mail/ImapTest.php'; require_once 'Zend/Mail/InterfaceTest.php'; require_once 'Zend/Mail/MessageTest.php'; +require_once 'Zend/Mail/SmtpOfflineTest.php'; require_once 'Zend/Mail/SmtpTest.php'; require_once 'Zend/Mail/FileTransportTest.php'; @@ -78,6 +79,7 @@ $suite->addTestSuite('Zend_Mail_MaildirFolderTest'); $suite->addTestSuite('Zend_Mail_MaildirWritableTest'); } + $suite->addTestSuite('Zend_Mail_SmtpOfflineTest'); if (defined('TESTS_ZEND_MAIL_SMTP_ENABLED') && constant('TESTS_ZEND_MAIL_SMTP_ENABLED') == true) { $suite->addTestSuite('Zend_Mail_SmtpTest'); } Index: tests/Zend/Mail/SmtpOfflineTest.php =================================================================== --- tests/Zend/Mail/SmtpOfflineTest.php (revision 0) +++ tests/Zend/Mail/SmtpOfflineTest.php (revision 0) @@ -0,0 +1,81 @@ +_params = array('host' => TESTS_ZEND_MAIL_SMTP_HOST, + 'port' => TESTS_ZEND_MAIL_SMTP_PORT, + 'username' => TESTS_ZEND_MAIL_SMTP_USER, + 'password' => TESTS_ZEND_MAIL_SMTP_PASSWORD, + 'auth' => TESTS_ZEND_MAIL_SMTP_AUTH); + } + + /** + * @group ZF-8988 + */ + public function testReturnPathIsUsedAsMailFrom() + { + $connectionMock = $this->getMock('Zend_Mail_Protocol_Smtp'); + $connectionMock->expects($this->once()) + ->method('mail') + ->with('return@example.com'); + + $transport = new Zend_Mail_Transport_Smtp($this->_params['host'], $this->_params); + $transport->setConnection($connectionMock); + + $mail = new Zend_Mail(); + $mail->setBodyText('This is a test.') + ->setFrom('from@example.com', 'from user') + ->setReturnPath('return@example.com'); + + $mail->send($transport); + } +} Index: library/Zend/Mail/Transport/Smtp.php =================================================================== --- library/Zend/Mail/Transport/Smtp.php (revision 23299) +++ library/Zend/Mail/Transport/Smtp.php (working copy) @@ -204,7 +204,7 @@ } // Set sender email address - $this->_connection->mail($this->_mail->getFrom()); + $this->_connection->mail($this->_mail->getReturnPath()); // Set recipient forward paths foreach ($this->_mail->getRecipients() as $recipient) {