Hi, I am glad people are being aware about email address verification rules :)
Many organizations don't even care alot about it.
First of all, in the computer industry there is a standard on email protocol. We call it RFC standard. This standard is a must for everything which is online.
Now since there is a standard on how to do emails, an email should be well structured... Your question might be is how do we let the user know that his email that he entered is well structured?
That is a good question, and the answer will be, the use of regular expression. Regular expressions, commonly known as "Reg Ex" are a set of key combinations that are meant to allow people to have a large variety of control over what they are searching for. Reg Ex is used a lot under Unix, and is common between many programs.
Every programming language has this functionality.
The pattern below would be the regular expression for checking if the email is a valid email..
Normally a email is split by a name and a domain name@domain
Lets discuss the NAME part:
Reg ex Pattern: ^[0-9a-z_]([-_.]?[0-9a-z])*
- The name, according to the RFC can only consist of letters and numbers with 2 characters a dot (.) and a underscore (_)
- The name must start with a number or a letter, it CANNOT start with a symbol (./_).
- It must contain a letter or a number and can contain at least 1 or more symbol . Note can, but it could not.
- The name must end with a letter or a number, but not a symbol.
The above is STANDARD! And it must be valid! And the Pattern
I posted above matches that statement!
Now lets discus the domain:
Pattern: [0-9a-z][-.0-9a-z]*\\.[a-z]{2,3}[.]?$
- Notice that it must contain a number or a letter to start with
- And it MUST contain a dot.
- It MAY contain a underscore or more dots.
- But AFTER the dot it MUST contain 2 or 3 letters ( i made it that way you could place 4 )
Okay now I explained the verification rules, but one might ask on how do we use them?
Look up regular expressions in your programming language, I will show you how I did it in PHP language.
/**
*
* Checks validity of an email
*
*@author
*Mohamed Mansour (m0.interactive@gmail.com)
*@param host
* string which is the email address
*@return
*Boolean
*
*/
function CheckEmailContact($host) {
if (eregi("^[0-9a-z_]([-_.]?[0-9a-z])*@[0-9a-z][-.0-9a-z]*\\.[a-z]{2,3}[.]?$", $host, $check)) {
$host = substr(strstr($check[0], '@'), 1).".";
if(function_exists('getmxrr')) {
if (getmxrr($host, $validate_email_temp) )
return TRUE;
} else {
return TRUE;
}
// This checks if dns is valid
if(function_exists('checkdnsrr')) {
if(checkdnsrr($host,"ANY"))
return TRUE;
} else {
return TRUE;
}
}
return FALSE;
}
Notice I used it... And notice there is a function within my programming language which tells me if the DOMAIN is a valid domain by simply pinging the domain.
I hope I helpeD!