From 104359d99345b3705dabb890bb5bc7450c795f3d Mon Sep 17 00:00:00 2001 From: Synchro Date: Fri, 18 Dec 2015 13:16:51 +0100 Subject: [PATCH] Fix extra line break in getSentMIMEMessage(), fixes #589 --- changelog.md | 1 + class.phpmailer.php | 2 +- test/phpmailerTest.php | 18 ++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index c4a2e5c4..dba30079 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # ChangeLog * Fix gmail XOAUTH2 scope, thanks to @sherryl4george +* Fix extra line break in getSentMIMEMessage() ## Version 5.2.14 (Nov 1st 2015) * Allow addresses with IDN (Internationalized Domain Name) in PHP 5.3+, thanks to @fbonzon diff --git a/class.phpmailer.php b/class.phpmailer.php index 2e284b21..a0ed242c 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -2074,7 +2074,7 @@ class PHPMailer */ public function getSentMIMEMessage() { - return $this->MIMEHeader . $this->mailHeader . self::CRLF . $this->MIMEBody; + return rtrim($this->MIMEHeader . $this->mailHeader, "\n\r") . self::CRLF . self::CRLF . $this->MIMEBody; } /** diff --git a/test/phpmailerTest.php b/test/phpmailerTest.php index 8958231f..a9812ff2 100644 --- a/test/phpmailerTest.php +++ b/test/phpmailerTest.php @@ -1507,6 +1507,24 @@ EOT; $this->assertTrue((strpos($b, 'To: "Tim \"The Book\" O\'Reilly" ') !== false)); } + /** + * Test MIME structure assembly. + */ + public function testMIMEStructure() + { + $this->Mail->Subject .= ': MIME structure'; + $this->Mail->Body = '

MIME structure test.

'; + $this->Mail->AltBody = 'MIME structure test.'; + $this->buildBody(); + $this->Mail->preSend(); + $this->assertRegExp( + "/Content-Transfer-Encoding: 8bit\r\n\r\n". + "This is a multi-part message in MIME format./", + $this->Mail->getSentMIMEMessage(), + 'MIME structure broken' + ); + } + /** * Test BCC-only addressing. */