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 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
|
I am running a php script that does a realtime check on valid emailadresses.
It works quit good on many mailservers but not on hotmail. I downloaded the
script from a website and modified it (the orginal has the same problems).
**** code snippet starts here ****
function validate_mail($to,$from)
{
list($me,$mydomain) = split("@",$from);
// Now look up the mail exchangers for the recipient
list($user,$domain) = split("@",$to,2);
if(getmxrr($domain,$mx,$weight) == 0) return FALSE;
// Try them in order of lowest weight first
array_multisort($mx,$weight);
$success=0;
foreach($mx as $host) {
// Open an SMTP connection
$connection = fsockopen ($host, 25, &$errno, &$errstr, 1);
if (!$connection)
continue;
$res=fgets($connection,256);
if(substr($res,0,3) != "220") break;
print("Open connection: $res<br><br>");
// Introduce ourselves
fputs($connection, "HELO $mydomain\n");
$res=fgets($connection,256);
if(substr($res,0,3) != "250") break;
print("HELO respons: $res<br><br>");
// Envelope from
fputs($connection, "MAIL FROM: $from\n");
$res=fgets($connection,256);
if(substr($res,0,3) != "250") break;
print("MAIL FROM respons: $res<br><br>");
// Envelope to
fputs($connection, "RCPT TO: $to\n");
$res=fgets($connection,256);
if(substr($res,0,3) != "250") break;
print("RCPT TO respons: $res<br><br>");
// Say bye bye
fputs($connection,"QUIT\n");
$res=fgets($connection,256);
if(substr($res,0,3) != "221") break;
print("QUIT: $res<br><br>");
$success=1;
break;
}
if($connection) {
if($success==0) fputs($connection, "QUIT\n");
fclose ($connection);
}
return $success?TRUE:FALSE;
}
$result = validate_mail("blabla@xxxxxxxxxxx",johndoe@xxxxxxxxxxx)
**** code snippet ends here ****
Hotmail stops responding when the connection is made. All other tested
providers work all the way to the end. Anyone an idea how to solve this? |
Partager