Hi guys,
I got an email validation here that U might find worthy.......but just a min. this thing's not working as I expected :
<?php
$checkthis="webmaster@hotmail.com";
$res=Array();
echo "checking...| ".$checkthis." | -- ";
$res= ValidateMail($checkthis);
$msg= $res[1];
echo $msg;
function ValidateMail($Email) {
global $HTTP_HOST;
$result = array();
if (!eregi("[a-z0-9-]+(.[a-z0-9-]+)@[a-z0-9-]+(.[a-z0-9-]+)(.[a-z]{2,3})$", $Email)) {
$result[0]=false;
$result[1]="$Email is not properly formatted";
return $result;
}
list ( $Username, $Domain ) = split ("@",$Email);
if (getmxrr($Domain, $MXHost)) {
$ConnectAddress = $MXHost[0];
} else {
$ConnectAddress = $Domain;
}
$Connect = fsockopen ( $ConnectAddress, 25 );
if ($Connect) {
if (ereg("^220", $Out = fgets($Connect, 1024))) {
fputs ($Connect, "HELO $HTTP_HOST\r\n");
$Out = fgets ( $Connect, 1024 );
fputs ($Connect, "MAIL FROM: <{$Email}>\r\n");
$From = fgets ( $Connect, 1024 );
fputs ($Connect, "RCPT TO: <{$Email}>\r\n");
$To = fgets ($Connect, 1024);
fputs ($Connect, "QUIT\r\n");
fclose($Connect);
if (!ereg ("^250", $From) ||
!ereg ( "250", $To )) {
$result[0]=false;
$result[1]="Server rejected address";
return $result;
}
} else {
$result[0] = false;
$result[1] = "No response from server";
return $result;
}
} else {
$result[0]=false;
$result[1]="Can not connect E-Mail server.";
return $result;
}
$result[0]=true;
$result[1]="$Email appears to be valid.";
return $result;
} // end of function
?>
the problem is when I give an address with "hotmail.com" as the domain it returns- "Server rejected address" ....and when its an address with "yahoo.com" it returns- "$Email appears to be valid."
can someone refine this script for me?
thankx.