- preg_match: documentation ( source)
- filter_var: documentation ( source)
- checkdnsrr: documentation ( source)
<?php
$email = 'geradolson5656@gmail.com';
if (checkEmailAndDomain($email)) {
echo 'Yes';
} else {
echo 'No';
}
function checkEmailAndDomain($email)
{
$exp = "/^(.*)@(.*)$/";
preg_match($exp, $email, $matches);
if (!empty($matches[1]) and (!filter_var($email, FILTER_VALIDATE_EMAIL)))
return (false);
return (checkdnsrr(idn_to_ascii($matches[2]), 'ANY'));
}