public function testReturnPath() { $mail = new Zend_Mail(); $res = $mail->setBodyText('This is a test.'); $mail->setFrom('*****@*****.**', 'test Mail User'); $mail->setSubject('My Subject'); $mail->addTo('*****@*****.**'); $mail->addTo('*****@*****.**'); $mail->addBcc('*****@*****.**'); $mail->addBcc('*****@*****.**'); $mail->addCc('*****@*****.**', 'Example no. 1 for cc'); $mail->addCc('*****@*****.**', 'Example no. 2 for cc'); // First example: from and return-path should be equal $mock = new Zend_Mail_Transport_Mock(); $mail->send($mock); $this->assertTrue($mock->called); $this->assertEquals($mail->getFrom(), $mock->returnPath); // Second example: from and return-path should not be equal $mail->setReturnPath('*****@*****.**'); $mock = new Zend_Mail_Transport_Mock(); $mail->send($mock); $this->assertTrue($mock->called); $this->assertNotEquals($mail->getFrom(), $mock->returnPath); $this->assertEquals($mail->getReturnPath(), $mock->returnPath); $this->assertNotEquals($mock->returnPath, $mock->from); }
public static function getFinalTransportForMail(Zend_Mail $mailObj, Zend_Mail_Transport_Abstract $transport) { $returnPath = $mailObj->getReturnPath(); if ($returnPath && $transport instanceof Zend_Mail_Transport_Sendmail) { $transportOption = XenForo_Application::getOptions()->get('emailTransport', false); if (!empty($transportOption['sendmailReturnPath']) && XenForo_Helper_Email::isEmailValid($returnPath)) { $config = '-f "' . $returnPath . '"'; } else { $config = null; } $transport = new Zend_Mail_Transport_Sendmail($config); } return $transport; }