function IsEmailAddrValid($email, $check_dns = false)
{
if(
(preg_match('/(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/', $email))
||
(preg_match('/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/', $email))
)
{
if($check_dns)
{
$host = explode('@', $email);
// Check for MX record
if( checkdnsrr($host[1], 'MX') ) return true;
// Check for A record
if( checkdnsrr($host[1], 'A') ) return true;
// Check for CNAME record
if( checkdnsrr($host[1], 'CNAME') ) return true;
}
else
{
return true;
}
} return false;
}
|