From 3cde873ee3876dcc0b0b22ea38d53374d2c098d0 Mon Sep 17 00:00:00 2001 From: Stewart Lord Date: Tue, 12 Feb 2013 01:02:17 -0800 Subject: [PATCH] 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(); } /**