Tuesday, 24 July 2018

fsockopen(): unable to connect not work with PHP (Connection timed out)

I have this code:

$domain = 'massag.com';

$hosts = array();
$mxweights = array();
getmxrr($domain, $hosts, $mxweights);

var_dump($hosts);
var_dump($mxweights);

$host = gethostbynamel($hosts[0])[0];
var_dump($host);

$f = @fsockopen($host, 25, $errno, $errstr, 10);

if(!$f) {
    var_dump('NOT CONNECTED');
}

It is not connected to smtp server but when I use command

smtp:217.196.209.9

on mxtoolbox.com it is connected.

Am I doing something wrong with PHP code? I already tried replace $host to smtp.massag.com but not helped.



from fsockopen(): unable to connect not work with PHP (Connection timed out)

No comments:

Post a Comment