From 6525e86940dfdd5cfeac690cb9ba801a02b8b4e6 Mon Sep 17 00:00:00 2001 From: Marcus Bointon Date: Thu, 30 Mar 2017 15:08:20 +0200 Subject: [PATCH 1/5] Handle bare codes (an RFC contravention) in SMTP replies, fixes #1017 --- changelog.md | 2 ++ class.smtp.php | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/changelog.md b/changelog.md index 5256844b..e8377558 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,7 @@ # ChangeLog +* Handle bare codes (an RFC contravention) in SMTP server responses + ## Version 5.2.23 (March 15th 2017) * Improve trapping of TLS errors during connection so that they don't cause warnings, and are reported better in debug output * Amend test suite so it uses PHPUnit version 4.8, compatible with older versions of PHP, instead of teh version supplied by Travis-CI diff --git a/class.smtp.php b/class.smtp.php index 01cee820..010a7aa6 100644 --- a/class.smtp.php +++ b/class.smtp.php @@ -1089,8 +1089,10 @@ class SMTP $this->edebug("SMTP -> get_lines(): \$data is \"$data\"", self::DEBUG_LOWLEVEL); $this->edebug("SMTP -> get_lines(): \$str is \"$str\"", self::DEBUG_LOWLEVEL); $data .= $str; - // If 4th character is a space, we are done reading, break the loop, micro-optimisation over strlen - if ((isset($str[3]) and $str[3] == ' ')) { + // If response is only 3 chars (not valid, but RFC5321 S4.2 says it must be handled), + // or 4th character is a space, we are done reading, break the loop, + // string array access is a micro-optimisation over strlen + if (!isset($str[3]) or (isset($str[3]) and $str[3] == ' ')) { break; } // Timed-out? Log and break From 1f974d0ab3ce24e81dfda168e2932ad290810acc Mon Sep 17 00:00:00 2001 From: Haci Murat Yaman Date: Mon, 3 Apr 2017 18:25:48 +0100 Subject: [PATCH 2/5] updated misleading comment on sample for smtp/google via xoauth2 #890 (#1019) * updated misleading comment on sample code for smtp.google.com via xoauth2 * undo change on gitignore --- examples/gmail_xoauth.phps | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/gmail_xoauth.phps b/examples/gmail_xoauth.phps index d64483a4..2aec1814 100644 --- a/examples/gmail_xoauth.phps +++ b/examples/gmail_xoauth.phps @@ -43,8 +43,8 @@ $mail->SMTPAuth = true; //Set AuthType $mail->AuthType = 'XOAUTH2'; -//User Email to use for SMTP authentication - Use the same Email used in Google Developer Console -$mail->oauthUserEmail = "someone@gmail.com"; +//User Email to use for SMTP authentication - user who gave consent to our app +$mail->oauthUserEmail = "from@gmail.com"; //Obtained From Google Developer Console $mail->oauthClientId = "RANDOMCHARS-----duv1n2.apps.googleusercontent.com"; From 42c7591bb56836e09afccb3c622fd3e6debbeee9 Mon Sep 17 00:00:00 2001 From: rsdifu Date: Sat, 8 Apr 2017 23:25:43 -0700 Subject: [PATCH 3/5] Date header should be more dynamic (#1023) When a message is sent, unless the MessageDate is explicitly set, the Date header should always be set to the current rfcDate() value. This is necessary for long-running processes that create a single PHPMailer instance, so all emails sent during the lifetime of the process don't have the same Date header value of the first email sent from the process. This is important because Gmail in particular, uses the Date header value to show how long ago an email was sent when viewing the email. (The list view in Gmail, however, uses the Received header value to show when an email was sent.) These differing times will lead to confusion for users, often resulting in them trying to do several things like updating their timezone in Google's settings, or on their computers, which would result in no resolution. --- class.phpmailer.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/class.phpmailer.php b/class.phpmailer.php index 1b31ec14..52c0e52d 100644 --- a/class.phpmailer.php +++ b/class.phpmailer.php @@ -2024,10 +2024,7 @@ class PHPMailer { $result = ''; - if ($this->MessageDate == '') { - $this->MessageDate = self::rfcDate(); - } - $result .= $this->headerLine('Date', $this->MessageDate); + $result .= $this->headerLine('Date', $this->MessageDate == '' ? self::rfcDate() : $this->MessageDate); // To be created automatically by mail() if ($this->SingleTo) { From 349350bc71c87dc40097d02e7a7abd864dd2df58 Mon Sep 17 00:00:00 2001 From: Marcus Bointon Date: Thu, 13 Apr 2017 12:23:28 +0200 Subject: [PATCH 4/5] Changelog --- changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/changelog.md b/changelog.md index e8377558..e3e812e4 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,7 @@ # ChangeLog * Handle bare codes (an RFC contravention) in SMTP server responses +* Make message timestamps more dynamic - calculate the date separately for each message ## Version 5.2.23 (March 15th 2017) * Improve trapping of TLS errors during connection so that they don't cause warnings, and are reported better in debug output From 9a0e074e109242b11943278a885fcd4fe6686eaf Mon Sep 17 00:00:00 2001 From: Marcus Bointon Date: Thu, 13 Apr 2017 12:24:19 +0200 Subject: [PATCH 5/5] Changelog --- changelog.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelog.md b/changelog.md index e3e812e4..cc036268 100644 --- a/changelog.md +++ b/changelog.md @@ -5,7 +5,7 @@ ## Version 5.2.23 (March 15th 2017) * Improve trapping of TLS errors during connection so that they don't cause warnings, and are reported better in debug output -* Amend test suite so it uses PHPUnit version 4.8, compatible with older versions of PHP, instead of teh version supplied by Travis-CI +* Amend test suite so it uses PHPUnit version 4.8, compatible with older versions of PHP, instead of the version supplied by Travis-CI * This forces pinning of some dev packages to older releases, but should make travis builds more reliable * Test suite now runs on HHVM, and thus so should PHPMailer in general * Improve Czech translations