Validate Email Server

Posted by hts | November 30, 2007 .

Suppose you have a form where the user has to input his email address (you can find such forms everywhere, can’t you?). Also, you don’t want to use the “activation” method to verify whether the email address is valid (that is, send an email to the specified address with an activation link - etc, you know the rest).

One simple method to verify whether an email address is valid is to see whether the domain points to a valid server.
Therefore, you get the domain from the full address (what’s after the “@” sign) and then ping that server. If it exists, then everything is okay and you can go on. Otherwise…do whatever you please to your user :)

Notes:

1.Obviously, the user might enter something like email-that-does-not-exist@gmail.com, and this script would still return a valid response. So, this script provides just a first step in validating an email address (first check if the email server exists, THEN send the activation email mentioned above - why send useless emails?)
2. the checkdnsrr() function works only on Linux platforms


function VerifyEmailAddress($EMail){
list($User, $Domain) = explode("@", $EMail);
$Result = checkdnsrr($Domain, 'MX');
return($Result);
}

Leave a Comment

If you would like to make a comment, please fill out the form below.

Name (required)

Email (required)

Website

Comments