diff --git a/library/Zend/Mail/Transport/Sendmail.php b/library/Zend/Mail/Transport/Sendmail.php index d5d607cf972..fbe8583fd01 100644 --- a/library/Zend/Mail/Transport/Sendmail.php +++ b/library/Zend/Mail/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); } diff --git a/tests/ZendTest/Mail/Transport/SendmailTest.php b/tests/ZendTest/Mail/Transport/SendmailTest.php index 9cde9ca59ef..0b6eebd048d 100644 --- a/tests/ZendTest/Mail/Transport/SendmailTest.php +++ b/tests/ZendTest/Mail/Transport/SendmailTest.php @@ -83,12 +83,12 @@ public function testReceivesMailArtifactsOnUnixSystems() $this->assertEquals('ZF DevTeam ', $this->to); $this->assertEquals('Testing Zend\Mail\Transport\Sendmail', $this->subject); $this->assertEquals('This is only a test.', trim($this->message)); - $this->assertNotContains("To: ZF DevTeam \r\n", $this->additional_headers); - $this->assertContains("Cc: matthew@zend.com\r\n", $this->additional_headers); - $this->assertContains("Bcc: \"CR-Team, ZF Project\" \r\n", $this->additional_headers); - $this->assertContains("From: zf-devteam@zend.com,\r\n Matthew \r\n", $this->additional_headers); - $this->assertContains("X-Foo-Bar: Matthew\r\n", $this->additional_headers); - $this->assertContains("Sender: Ralph Schindler \r\n", $this->additional_headers); + $this->assertNotContains("To: ZF DevTeam \n", $this->additional_headers); + $this->assertContains("Cc: matthew@zend.com\n", $this->additional_headers); + $this->assertContains("Bcc: \"CR-Team, ZF Project\" \n", $this->additional_headers); + $this->assertContains("From: zf-devteam@zend.com,\n Matthew \n", $this->additional_headers); + $this->assertContains("X-Foo-Bar: Matthew\n", $this->additional_headers); + $this->assertContains("Sender: Ralph Schindler \n", $this->additional_headers); $this->assertEquals('-R hdrs -f ralph.schindler@zend.com', $this->additional_parameters); }