Handle early connection errors, see #2211
This commit is contained in:
parent
338b5597ac
commit
5050b6012f
|
|
@ -1,5 +1,8 @@
|
|||
# PHPMailer Change Log
|
||||
|
||||
## WIP
|
||||
* Handle early connection errors such as 421
|
||||
|
||||
## Version 6.2.0
|
||||
* PHP 8.0 compatibility, many thanks to @jrf_nl!
|
||||
* Switch from PHP CS Fixer to PHP CodeSniffer for coding standards
|
||||
|
|
|
|||
16
src/SMTP.php
16
src/SMTP.php
|
|
@ -343,8 +343,20 @@ class SMTP
|
|||
// Get any announcement
|
||||
$this->last_reply = $this->get_lines();
|
||||
$this->edebug('SERVER -> CLIENT: ' . $this->last_reply, self::DEBUG_SERVER);
|
||||
|
||||
return true;
|
||||
$responseCode = (int)substr($this->last_reply, 0, 3);
|
||||
if ($responseCode === 220) {
|
||||
return true;
|
||||
}
|
||||
//Anything other than a 220 response means something went wrong
|
||||
//RFC 5321 says the server will wait for us to send a QUIT in response to a 554 error
|
||||
//https://tools.ietf.org/html/rfc5321#section-3.1
|
||||
if ($responseCode === 554) {
|
||||
$this->quit();
|
||||
}
|
||||
//This will handle 421 responses which may not wait for a QUIT (e.g. if the server is being shut down)
|
||||
$this->edebug('Connection: closing due to error', self::DEBUG_CONNECTION);
|
||||
$this->close();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue