1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| function send_command($fp, $out){
fwrite($fp, $out . "\r\n");
return get_data($fp);
}
function get_data($fp){
$s="";
stream_set_timeout($fp, 2);
for($i=0;$i<2;$i++)
$s.=fgets($fp, 1024);
return $s;
}
function CheckMX($mx_host, $eMail)
{
$code = 0;
$fp = @fsockopen($mx_host, 25, $errno, $errstr, 2);
if ($fp) {
send_command($fp, 'HELO microsoft.com');
send_command($fp, 'MAIL FROM:<support@microsoft.com>');
$erg = send_command($fp, 'RCPT TO:<'.$eMail.'>');
fclose($fp);
$code = intval(substr($erg, 0, 3));
}
return $code;
}
$eMail = "mail@fai.fr";
getmxrr("fai.fr", $mx_records);
foreach ($mx_records as $mx_host)
{
$code = CheckMX($mx_host, $eMail);
if ($code == 451)
{
//Le serveur dispose du systeme greylisting. Il faut réessayer dans 5 min
echo"Greylisting...";
}
if ($code == 250)
{
echo"email existe bien";
break;
}
else
{
echo"l email n existe pas";
}
} |
Partager