Skip to content

Commit

Permalink
Merge branch 'hotfix/5422'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Nov 6, 2013
2 parents b29d75b + 4ad8044 commit c2c407d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
5 changes: 5 additions & 0 deletions library/Zend/Mail/Protocol/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ public function data($data)
$this->_send('DATA');
$this->_expect(354, 120); // Timeout set for 2 minutes as per RFC 2821 4.5.3.2

// Ensure newlines are CRLF (\r\n)
if (PHP_EOL === "\n") {
$data = str_replace("\n", "\r\n", str_replace("\r", '', $data));
}

foreach (explode(self::EOL, $data) as $line) {
if (strpos($line, '.') === 0) {
// Escape lines prefixed with a '.'
Expand Down
28 changes: 28 additions & 0 deletions tests/ZendTest/Mail/Protocol/SmtpTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,34 @@ public function testSendMinimalMail()
$this->assertEquals($expectedMessage, $this->connection->getLog());
}

public function testSendEscapedEmail()
{
$headers = new Headers();
$headers->addHeaderLine('Date', 'Sun, 10 Jun 2012 20:07:24 +0200');
$message = new Message();
$message
->setHeaders($headers)
->setSender('[email protected]', 'Ralph Schindler')
->setBody("This is a test\n.")
->addTo('[email protected]', 'ZF DevTeam')
;
$expectedMessage = "EHLO localhost\r\n"
. "MAIL FROM:<[email protected]>\r\n"
. "DATA\r\n"
. "Date: Sun, 10 Jun 2012 20:07:24 +0200\r\n"
. "Sender: Ralph Schindler <[email protected]>\r\n"
. "To: ZF DevTeam <[email protected]>\r\n"
. "\r\n"
. "This is a test\r\n"
. "..\r\n"
. ".\r\n";

$this->transport->send($message);

$this->assertEquals($expectedMessage, $this->connection->getLog());

}

public function testDisconnectCallsQuit()
{
$this->connection->disconnect();
Expand Down

0 comments on commit c2c407d

Please sign in to comment.