Fix delivery issues with long subject lines and MailTransport.

A few people have reported issues sending wrapped messages via
MailTransport. Removing the new lines has been suggested as a fix.

Refs #2176
This commit is contained in:
mark_story 2013-10-23 12:41:57 -04:00
parent b4a0182bf0
commit 23b23d8050
2 changed files with 3 additions and 2 deletions

View file

@ -42,9 +42,10 @@ class MailTransport extends AbstractTransport {
unset($headers['To']); unset($headers['To']);
$headers = $this->_headersToString($headers, $eol); $headers = $this->_headersToString($headers, $eol);
$message = implode($eol, $email->message()); $message = implode($eol, $email->message());
$subject = str_replace(array("\r", "\n"), '', $email->subject());
$params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null; $params = isset($this->_config['additionalParameters']) ? $this->_config['additionalParameters'] : null;
$this->_mail($to, $email->subject(), $message, $headers, $params); $this->_mail($to, $subject, $message, $headers, $params);
return array('headers' => $headers, 'message' => $message); return array('headers' => $headers, 'message' => $message);
} }

View file

@ -69,7 +69,7 @@ class MailTransportTest extends CakeTestCase {
$data .= "Content-Transfer-Encoding: 8bit"; $data .= "Content-Transfer-Encoding: 8bit";
$subject = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?='; $subject = '=?UTF-8?B?Rm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXogRm/DuCBCw6VyIELDqXog?=';
$subject .= "\r\n" . ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?='; $subject .= ' =?UTF-8?B?Rm/DuCBCw6VyIELDqXo=?=';
$this->MailTransport->expects($this->once())->method('_mail') $this->MailTransport->expects($this->once())->method('_mail')
->with( ->with(
'CakePHP <cake@cakephp.org>', 'CakePHP <cake@cakephp.org>',