I'm running a website with more than 60 000 registered users. Every week notifications are send to these users via email, now I've noticed some of the mail addresses do not exists anymore eg. the domain address is valid but the email name en asdas@ is not valid anymore since person does not work at a company anymore etc. Now I'm looping through the database and doing some regular expression checks and
checking if the MX records exist with the following two functions
function verify_email($email){
if(!preg_match('/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,4})$/',$email)){
return false;
} else {
return true;
}
}
// Our function to verify the MX records
function verify_email_dns($email){
list($name, $domain) = split('@',$email);
if(!checkdnsrr($domain,'MX')){
return false;
} else {
return true;
}
}
If the email address is in an invalid format or the domain does not exists I delete the users account. Are there any methods I could use to check if the email address still exists or not if the domain name is valid and the email address is in the correct format? For example
[email protected] does not exist anymore but test.com is a valid domain name.