Permalink
Browse files

Merge pull request #639 from suzuki/2.2-fix-smtp-transparency

Fix SMTP Transparency
  • Loading branch information...
2 parents fe0c7d3 + 05bcc4f commit 900184439665f8ec6ae6421b2cf5638dd2d07ef0 @markstory markstory committed May 9, 2012
@@ -1238,9 +1238,6 @@ protected function _wrap($message) {
$formatted[] = '';
continue;
}
- if ($line[0] === '.') {
- $line = '.' . $line;
- }
if (!preg_match('/\<[a-z]/i', $line)) {
$formatted = array_merge($formatted, explode("\n", wordwrap($line, self::LINE_LENGTH_SHOULD, "\n")));
continue;
@@ -168,7 +168,16 @@ protected function _sendData() {
$headers = $this->_cakeEmail->getHeaders(array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'subject'));
$headers = $this->_headersToString($headers);
- $message = implode("\r\n", $this->_cakeEmail->message());
+ $lines = $this->_cakeEmail->message();
+ $messages = array();
+ foreach ($lines as $line) {
+ if ((!empty($line)) && ($line[0] === '.')) {
+ $messages[] = '.' . $line;
+ } else {
+ $messages[] = $line;
+ }
+ }
+ $message = implode("\r\n", $messages);
$this->_smtpSend($headers . "\r\n\r\n" . $message . "\r\n\r\n\r\n.");
$this->_content = array('headers' => $headers, 'message' => $message);
}
@@ -51,7 +51,7 @@ public function testSend() {
$email->subject('Testing Message');
$date = date(DATE_RFC2822);
$email->setHeaders(array('X-Mailer' => DebugCakeEmail::EMAIL_CLIENT, 'Date' => $date));
- $email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '')));
+ $email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '.Third Line', '')));
$headers = "From: CakePHP Test <noreply@cakephp.org>\r\n";
$headers .= "To: CakePHP <cake@cakephp.org>\r\n";
@@ -66,6 +66,7 @@ public function testSend() {
$data = "First Line\r\n";
$data .= "Second Line\r\n";
+ $data .= ".Third Line\r\n"; // Not use 'RFC5321 4.5.2.Transparency' in DebugTransport.
$result = $this->DebugTransport->send($email);
@@ -221,7 +221,7 @@ public function testSendData() {
$email->subject('Testing SMTP');
$date = date(DATE_RFC2822);
$email->setHeaders(array('X-Mailer' => SmtpCakeEmail::EMAIL_CLIENT, 'Date' => $date));
- $email->expects($this->any())->method('message')->will($this->returnValue(array('First Line', 'Second Line', '')));
+ $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";
@@ -237,6 +237,7 @@ public function testSendData() {
$data .= "\r\n";
$data .= "First Line\r\n";
$data .= "Second Line\r\n";
+ $data .= "..Third Line\r\n"; // RFC5321 4.5.2.Transparency
$data .= "\r\n";
$data .= "\r\n\r\n.\r\n";

0 comments on commit 9001844

Please sign in to comment.