لقيت حل ممكن يفيدك بهذا الخصوص
This function takes an email address and checks to make sure it is valid. It will check first for valid format of the email address, and then it will check to make sure the host that has been entered exists and has a MX record.
The original function I wrote went a bit further, and actually connected to the server to verify the account, but I ran into problems with email hosts like hotmail and yahoo.
This function will return an array with "status" being true or false, and "msg" being either the error message, or if sucessfull, the email address.
array validEmail ( string email_address )
كود PHP:
function validEmail($email)
{
$return = array();
if (!eregi("^[0-9a-z_]([-_.]?[0-9a-z])*@[0-9a-z][-.0-9a-z]*\.[a-z]{2,4}[.]?$",$email, $check))
{
$return["status"] = false;
$return["msg"] = 'Error: Invalid e-mail address.';
return $return;
}
$host = substr(strstr($check[0], '@'), 1);
if (!checkdnsrr($host.'.',"MX"))
{
$return["status"] = false;
$return["msg"] = 'Error: Invalid host';
return $return;
}
$return["status"] = true;
$return["msg"] = $email;
return $return;
}