diff --git a/extend/phpmailer/PHPMailer.php b/extend/phpmailer/PHPMailer.php index 0d38879bc96153b892f83528087feb957e3a5fff..accf9ac52330078a614e4f252e75a02b3dc85a2e 100644 --- a/extend/phpmailer/PHPMailer.php +++ b/extend/phpmailer/PHPMailer.php @@ -1770,9 +1770,10 @@ class PHPMailer */ protected function smtpSend($header, $body) { + try { $bad_rcpt = []; if (!$this->smtpConnect($this->SMTPOptions)) { - throw new \Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); + throw new Exception($this->lang('smtp_connect_failed'), self::STOP_CRITICAL); } //Sender already validated in preSend() if ('' == $this->Sender) { @@ -1841,6 +1842,12 @@ class PHPMailer } return true; + } catch (Exception $exc) { + $lastexception = $exc; + $this->edebug($exc->getMessage()); + // We must have connected, but then failed TLS or Auth, so close connection nicely + $this->smtp->quit(); + } } /**