note 74809 deleted from function.checkdnsrr by googleguy
| From: | googleguy@php.net | Date: | Tue, 22 Oct 2013 06:44:19 +0000 |
| Subject: | note 74809 deleted from function.checkdnsrr by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-196618@lists.php.net to get a copy of this message | ||
Note Submitter: reportingsjr at gmail dot com
----
Here is a modification to the note below:
function check_email($email) {
if(preg_match('/^\w[-.\w]*@(\w[-._\w]*\.[a-zA-Z]{2,}.*)$/', $email, $matches))
{
if(function_exists('checkdnsrr'))
{
if(checkdnsrr($matches[1] . '.', 'MX')) return true;
if(checkdnsrr($matches[1] . '.', 'A')) return true;
}else{
if(!empty($hostName))
{
if( $recType == '' ) $recType = "MX";
exec("nslookup -type=$recType $hostName", $result);
foreach ($result as $line)
{
if(eregi("^$hostName",$line))
{
return true;
}
}
return false;
}
return false;
}
}
return false;
}
This makes it compatible with windows and will make sure it actually checks the domain.