Jump to content

php email check


perezf

Recommended Posts

I'm not aware of a way to validate email existence, and if it exists, it must be a bit complicated. What I know, is a way of checking if the mail domain has mx records. Normally, as suggested previously you must run a regular expression to validate the email format. Consider this code:

 

<?php
$email = '[email protected]';
list($name, $domain) = explode('@', $email); //will explode the '@' to get two variables for the domain and name
if(checkdnsrr($domain, 'MX')){ //will check the dns of the domain for any MX records. you can discard the second parameter as the default is 'MX' but i wrote it for you to understand it
    echo 'Your email is valid.';
} else{
    echo 'Sorry, email invalid.';
}
?>

 

Unfortunately (or not) you can't use this function in windows platforms, but maybe a command such as "nslookup" can be used in the same way. Hope someone can give you a better method.

Link to comment
https://forums.phpfreaks.com/topic/120639-php-email-check/#findComment-621829
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.