When using this class in my work, I found some problems.
for detect the problem, must be supplemented by the condition in a loop foreach (method check)
foreach ($mxs as $host) {
if ($fp = fsockopen($host, $this->_port, $errno, $errstr, $this->_timeout)) {
stream_set_timeout($fp, $this->_timeout);
$reply = fgets($fp);
preg_match('/^(?<code>[0-9]{3}) (.*)$/ims', $reply, $matches);
$code = isset($matches['code']) ? $matches['code'] : '';
if ($code = '220') {
break;
} else {
fclose($fp);
}
} else {
echo 'HOST: '.$host.'<br>';
echo 'error No: '.$errno.'<br>';
echo 'error Msg: '.$errstr.'<br>';
}
}
1. On your server there is a firewall which locks connections with other servers.
example.php displays an error message:
HOST: gmail-smtp-in.l.google.com
error No: 13
error Msg: Permission denied
HOST: alt1.gmail-smtp-in.l.google.com
error No: 13
error Msg: Permission denied
HOST: alt2.gmail-smtp-in.l.google.com
error No: 13
error Msg: Permission denied
HOST: alt3.gmail-smtp-in.l.google.com
error No: 13
error Msg: Permission denied
HOST: alt4.gmail-smtp-in.l.google.com
error No: 13
error Msg: Permission denied
email <
[email protected]> valid, but not exist!
2. On your server, ports for connection to an exterior network are closed.
example.php displays an error message:
HOST: gmail-smtp-in.l.google.com
error No: 61
error Msg: Connection refused
HOST: alt1.gmail-smtp-in.l.google.com
error No: 61
error Msg: Connection refused
HOST: alt2.gmail-smtp-in.l.google.com
error No: 61
error Msg: Connection refused
HOST: alt3.gmail-smtp-in.l.google.com
error No: 61
error Msg: Connection refused
HOST: alt4.gmail-smtp-in.l.google.com
error No: 61
error Msg: Connection refused
email <
[email protected]>; valid, but not exist!