From 3cde873ee3876dcc0b0b22ea38d53374d2c098d0 Mon Sep 17 00:00:00 2001 From: Stewart Lord Date: Tue, 12 Feb 2013 01:02:17 -0800 Subject: [PATCH 1/3] Cast a wider net for EOL translation. The to and subject headers were being independantly wrapped. Now we convert line-endings on $to, $subject, $body and $headers immediately before calling mail(). --- src/Transport/Sendmail.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/Transport/Sendmail.php b/src/Transport/Sendmail.php index 5a1f73fd..fbe8583f 100644 --- a/src/Transport/Sendmail.php +++ b/src/Transport/Sendmail.php @@ -127,6 +127,15 @@ public function send(Mail\Message $message) $headers = $this->prepareHeaders($message); $params = $this->prepareParameters($message); + // On *nix platforms, we need to replace \r\n with \n + // sendmail is not an SMTP server, it is a unix command - it expects LF + if (!$this->isWindowsOs()) { + $to = str_replace("\r\n", "\n", $to); + $subject = str_replace("\r\n", "\n", $subject); + $body = str_replace("\r\n", "\n", $body); + $headers = str_replace("\r\n", "\n", $headers); + } + call_user_func($this->callable, $to, $subject, $body, $headers, $params); } @@ -190,9 +199,8 @@ protected function prepareSubject(Mail\Message $message) protected function prepareBody(Mail\Message $message) { if (!$this->isWindowsOs()) { - // On *nix platforms, we should replace \r\n with \n - // sendmail is not an SMTP server, it is a unix command - it expects LF - return str_replace("\r\n", "\n", $message->getBodyText()); + // *nix platforms can simply return the body text + return $message->getBodyText(); } // On windows, lines beginning with a full stop need to be fixed @@ -218,10 +226,7 @@ protected function prepareHeaders(Mail\Message $message) $headers = clone $message->getHeaders(); $headers->removeHeader('To'); $headers->removeHeader('Subject'); - - // On *nix platforms, we should replace \r\n with \n - // sendmail is not an SMTP server, it is a unix command - it expects LF - return str_replace("\r\n", "\n", $headers->toString()); + return $headers->toString(); } /** From 3dc09b113ad3155e59e585573e59925cdb3ef501 Mon Sep 17 00:00:00 2001 From: Adam Date: Fri, 15 Feb 2013 12:12:57 +0100 Subject: [PATCH 2/3] Update library/Zend/Mail/Header/AbstractAddressList.php because [ErrorException] Notice: Undefined offset: 1 in vendor/zendframe work/zendframework/library/Zend/Mail/Header/AbstractAddressList.php line 46 --- src/Header/AbstractAddressList.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Header/AbstractAddressList.php b/src/Header/AbstractAddressList.php index 97cbd5f1..737e36fe 100644 --- a/src/Header/AbstractAddressList.php +++ b/src/Header/AbstractAddressList.php @@ -43,7 +43,9 @@ public static function fromString($headerLine) { $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); // split into name/value - list($fieldName, $fieldValue) = explode(': ', $decodedLine, 2); + list($fieldName, $fieldValue) = explode(':', $decodedLine, 2); + $fieldName = \trim($fieldName); + $fieldValue = \trim($fieldValue); if (strtolower($fieldName) !== static::$type) { throw new Exception\InvalidArgumentException(sprintf( From 0fc2471d6fabc1c368872dbf6acdced0677f9a54 Mon Sep 17 00:00:00 2001 From: Matthew Weier O'Phinney Date: Tue, 19 Feb 2013 15:16:41 -0600 Subject: [PATCH 3/3] [zendframework/zf2#3789] Remove namespace qualifier from function calls --- src/Header/AbstractAddressList.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Header/AbstractAddressList.php b/src/Header/AbstractAddressList.php index 737e36fe..6f801933 100644 --- a/src/Header/AbstractAddressList.php +++ b/src/Header/AbstractAddressList.php @@ -44,8 +44,8 @@ public static function fromString($headerLine) $decodedLine = iconv_mime_decode($headerLine, ICONV_MIME_DECODE_CONTINUE_ON_ERROR, 'UTF-8'); // split into name/value list($fieldName, $fieldValue) = explode(':', $decodedLine, 2); - $fieldName = \trim($fieldName); - $fieldValue = \trim($fieldValue); + $fieldName = trim($fieldName); + $fieldValue = trim($fieldValue); if (strtolower($fieldName) !== static::$type) { throw new Exception\InvalidArgumentException(sprintf(