//Get any announcement
$this->last_reply =
$this->
get_lines();
$this->
edebug('SERVER -> CLIENT: ' .
$this->last_reply, self::DEBUG_SERVER
);
$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;
} /**
* Create connection to the SMTP server.
*
* @param string $host SMTP server IP or host name
* @param int $port The port number to connect to
* @param int $timeout How long to wait for the connection to open
* @param array $options An array of options for stream_context_create()
*
* @return false|resource
*/