One way to do it is to check for MX records -
function checkmail ($s) {
$emailcmpstr = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM-.@_1234567890";
$host = substr ($s, strrpos($s, '@') + 1, strlen($s) - strrpos($s, '@'));
if (strspn ($s, $emailcmpstr) != strlen($s)) {return false;}
if (!checkdnsrr ($host, "MX")) {
$host_array=explode(".",$host);
$host=$host_array[sizeof($host_array)-2].".".$host_array[sizeof($host_array)-1];
if (!checkdnsrr ($host, "MX")) {
return false;
}
}
return true;
}
Hope this helps 😉
P.S. Note the dns checking functions do not work on windows