Don't try to issue RSET on connection errors

In case of errors, keep-alive SMTP connections are always reset, but
when the error happened while establishing the connection, trying to
reset the connection is pointless and just produces another error.
This commit is contained in:
Björn Steinbrink 2022-09-21 13:52:41 +02:00
parent 410086d03e
commit 703ad1052c
1 changed files with 1 additions and 1 deletions

View File

@ -1671,7 +1671,7 @@ class PHPMailer
return $this->mailSend($this->MIMEHeader, $this->MIMEBody);
}
} catch (Exception $exc) {
if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true) {
if ($this->Mailer === 'smtp' && $this->SMTPKeepAlive == true && $this->smtp->connected()) {
$this->smtp->reset();
}
$this->setError($exc->getMessage());