Many times we use to get the user’s mail id in our form. Through the regex we just check the entered style of mail id. Mail id having @ or not or having any tld or not and all. But is it really a validation of mail id ? I think no validation means that the mail id and tld are really exists or not. let me tell you how you can validate the mail id. Use the below code to validate the mail id.
<?php
function domain_exists($email, $record = 'MX'){
list($user, $domain) = explode('@', $email);
return checkdnsrr($domain, $record);
}
if(domain_exists('vivek@simplyitsols.com')) {
echo('This MX records exists; I will accept this email as valid.');
}
else {
echo('No MX record exists; Invalid email.');
}
?>
🙂