From 8164d38e3b3bd3b2ae679552cf4175aa15bd96a3 Mon Sep 17 00:00:00 2001 From: George Wilson Date: Mon, 13 May 2019 13:54:33 +0100 Subject: [PATCH 1/3] [4.0] Fix JMail workaround for opportunistic tls --- libraries/src/Mail/Mail.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libraries/src/Mail/Mail.php b/libraries/src/Mail/Mail.php index c9d658b240c65..2c2436195e42b 100644 --- a/libraries/src/Mail/Mail.php +++ b/libraries/src/Mail/Mail.php @@ -100,7 +100,7 @@ public static function getInstance($id = 'Joomla', $exceptions = true) * @since 1.7.0 * * @throws \RuntimeException if the mail function is disabled - * @throws phpmailerException if sending failed and exception throwing is enabled + * @throws phpmailerException if sending failed */ public function Send() { @@ -133,7 +133,11 @@ public function Send() */ if (!$result && $this->SMTPAutoTLS) { - throw new \RuntimeException(Text::_($this->ErrorInfo), 500); + $this->SMTPAutoTLS = true; + $result = parent::send(); + + // Reset the value for any future emails + $this->SMTPAutoTLS = false; } return $result; From 3371447c9f8ae5e11edf1a684902542c7ad5c224 Mon Sep 17 00:00:00 2001 From: George Wilson Date: Mon, 13 May 2019 13:59:03 +0100 Subject: [PATCH 2/3] Wrong way around :) --- libraries/src/Mail/Mail.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/src/Mail/Mail.php b/libraries/src/Mail/Mail.php index 2c2436195e42b..2c6956aabeead 100644 --- a/libraries/src/Mail/Mail.php +++ b/libraries/src/Mail/Mail.php @@ -133,11 +133,11 @@ public function Send() */ if (!$result && $this->SMTPAutoTLS) { - $this->SMTPAutoTLS = true; + $this->SMTPAutoTLS = false; $result = parent::send(); // Reset the value for any future emails - $this->SMTPAutoTLS = false; + $this->SMTPAutoTLS = true; } return $result; From 943769981f85ed641a4e2c14faaf143bab42c107 Mon Sep 17 00:00:00 2001 From: George Wilson Date: Mon, 13 May 2019 14:39:51 +0100 Subject: [PATCH 3/3] Rest the value in a finally --- libraries/src/Mail/Mail.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libraries/src/Mail/Mail.php b/libraries/src/Mail/Mail.php index 2c6956aabeead..b69279b688a95 100644 --- a/libraries/src/Mail/Mail.php +++ b/libraries/src/Mail/Mail.php @@ -134,10 +134,16 @@ public function Send() if (!$result && $this->SMTPAutoTLS) { $this->SMTPAutoTLS = false; - $result = parent::send(); - // Reset the value for any future emails - $this->SMTPAutoTLS = true; + try + { + $result = parent::send(); + } + finally + { + // Reset the value for any future emails + $this->SMTPAutoTLS = true; + } } return $result;