mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge pull request #1349 from renansaddam/smtpTransportReturnPath
Using Return-Path email address in MAIL FROM instead of a header in SmtpTransport
This commit is contained in:
commit
2f93d781ad
2 changed files with 27 additions and 3 deletions
|
@ -161,7 +161,10 @@ class SmtpTransport extends AbstractTransport {
|
|||
* @throws SocketException
|
||||
*/
|
||||
protected function _sendRcpt() {
|
||||
$from = $this->_cakeEmail->from();
|
||||
$from = $this->_cakeEmail->returnPath();
|
||||
if (empty($from)) {
|
||||
$from = $this->_cakeEmail->from();
|
||||
}
|
||||
$this->_smtpSend('MAIL FROM:<' . key($from) . '>');
|
||||
|
||||
$to = $this->_cakeEmail->to();
|
||||
|
@ -182,7 +185,7 @@ class SmtpTransport extends AbstractTransport {
|
|||
protected function _sendData() {
|
||||
$this->_smtpSend('DATA', '354');
|
||||
|
||||
$headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
|
||||
$headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'to', 'cc', 'subject'));
|
||||
$headers = $this->_headersToString($headers);
|
||||
$lines = $this->_cakeEmail->message();
|
||||
$messages = array();
|
||||
|
|
|
@ -270,6 +270,28 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$this->SmtpTransport->sendRcpt();
|
||||
}
|
||||
|
||||
/**
|
||||
* testRcptWithReturnPath method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testRcptWithReturnPath() {
|
||||
$email = new CakeEmail();
|
||||
$email->from('noreply@cakephp.org', 'CakePHP Test');
|
||||
$email->to('cake@cakephp.org', 'CakePHP');
|
||||
$email->returnPath('pleasereply@cakephp.org', 'CakePHP Return');
|
||||
|
||||
$this->socket->expects($this->at(0))->method('write')->with("MAIL FROM:<pleasereply@cakephp.org>\r\n");
|
||||
$this->socket->expects($this->at(1))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(2))->method('read')->will($this->returnValue("250 OK\r\n"));
|
||||
$this->socket->expects($this->at(3))->method('write')->with("RCPT TO:<cake@cakephp.org>\r\n");
|
||||
$this->socket->expects($this->at(4))->method('read')->will($this->returnValue(false));
|
||||
$this->socket->expects($this->at(5))->method('read')->will($this->returnValue("250 OK\r\n"));
|
||||
|
||||
$this->SmtpTransport->setCakeEmail($email);
|
||||
$this->SmtpTransport->sendRcpt();
|
||||
}
|
||||
|
||||
/**
|
||||
* testSendData method
|
||||
*
|
||||
|
@ -290,7 +312,6 @@ class SmtpTransportTest extends CakeTestCase {
|
|||
$email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
|
||||
|
||||
$data = "From: CakePHP Test <noreply@cakephp.org>\r\n";
|
||||
$data .= "Return-Path: CakePHP Return <pleasereply@cakephp.org>\r\n";
|
||||
$data .= "To: CakePHP <cake@cakephp.org>\r\n";
|
||||
$data .= "Cc: Mark Story <mark@cakephp.org>, Juan Basso <juan@cakephp.org>\r\n";
|
||||
$data .= "X-Mailer: CakePHP Email\r\n";
|
||||
|
|
Loading…
Reference in a new issue