Beside being able to locate MX Records, aspNetMX has a powerful email validation engine to validate either one email address or millions of email addresses.
Before proceeding any further, we must state that aspNetMX cannot be used for any spamming purposes, email address harvesting, or any other illegal purposes. This would violate the aspNetMX license agreement.
The core validation method of aspNetMX, is the MXValidate.Validate() method. There are various derivatives and overloads of this method, but the one will discuss here is the
MXValidateLevel level = mx.Validate(EmailAddress, MXValidateLevel.Mailbox) version.
aspNetMX validates email addresses at 4 different levels. These levels include:
MXValidateLevel.NotValid
MXValidateLevel.Syntax
MXValidateLevel.MXRecords
MXValidateLevel.SMTP
MXValidateLevel.Mailbox
Each of these levels will be discussed below.
MXValidateLevel.NotValid
The email address is not checked for validation.
MXValidateLevel.Syntax
The syntax level is the easiest validation to perform. When an email is checked for MXValidateLevel.Syntax, the email address is verified it is syntactically correct.
MXValidateLevel.MXRecords
Checks to see if an email address is both syntactically correct and makes a DNS call to verify the domain name part of an email address has MX Records.
MXValidateLevel.SMTP
Checks all of the above levels, and verifies a successful connection to an email address's mail server.
MXValidateLevel.Mailbox
Checks all of the above levels, and verifies that a mailbox exists for the email address.
When Validate() is executed, it attempts to validate an email address UP TO the level that was specified. If the validation was successful, it returns that level. If the validation was NOT successful, it returns the last highest level of validation that was found. This allows you to vary actions, based upon the level of validation returned. For example
MXValidate mx = new MXValidate();
string email = "test@hotmail.com";
MXValidateLevel level = mx.Validate( email, MXValidateLevel.Mailbox );
switch( level )
{
case MXValidateLevel.NotValid:
//bad email address, remove from email address list
break;
case MXValidateLevel.Syntax:
//the email address is syntactically correct
break;
case MXValidateLevel.MXRecords:
//mx records were found, but for some reason
//the SMTP server couldn't be found
//save email for checking later, and see if SMTP servers fail
again
break;
case MXValidateLevel.SMTP:
//able to connect to the mail server
//but mail server said email address was bad
//remove from list
break;
case MXValidateLevel.Mailbox:
//the email address validated to the mail box level
//and the mail server will accept email for that address
break;
}
Allows you to take different actions based upon the result from aspNetMX. If only MXValidateLevel.MXRecords was achieved, perhaps a network connection was down, and the email address could be flagged for later validation, where as if MXValidateLevel.SMTP was returned, that means a successful connection was made to the mail server, but for some reason it was rejected. The email address is probably bad.
Email validation is a tricky process. aspNetMX has made this process incredibly simple and powerful. The only correct way to verify an email address exists is to send a mailbox an email and see if you receive a bounce back email or NDR (Non-Deliverable Receipt). aspNetMX goes as far as possible in attempting to validate email addresses WITHOUT sending an actual email.
There are a couple of issues to be aware of when validating email addresses at the MXValidateLevel.Mailbox level.
Positive Validation when a Mailbox doesn't exist
Some mail servers always return a positive response that a mailbox exists, and it is only until an email is sent to a mailbox, that the server responds with a negative response saying a mailbox does not exist. Microsoft's exchange server is notorious for doing this. However, we have optimized aspNetMX to help with this situation, and return faster results against these known servers.
MXValidateLevel.Mailbox can be a Time Intensive Process
To better explain what happens under the covers when an email addresses is tested to Mailbox level, the following steps occur:
1. The email addresses is syntactically checked.
2. If the email address is valid, a DNS Lookup for MX Records is made. This involves network calls to DNS Servers to see if MX Records exist. If the binary MX Records exist, and are returned to aspNetMX, aspNetMX turns the records into a usable form.
3. If the MX Records return the names of the Mail Servers, and not the IP addresses of the mail servers, another DNS call is made to lookup the actual IP addresses.
4. Once the IP addresses have been determined, another network call is made, this time to the email address's SMTP server. If the mail server is not responding, and there are fail over MX Records, aspNetMX will resolve each of the additional MX Records to IP addresses and then attempt to make a successful SMTP connection.
5. Once a SMTP session has been established, standard SMTP command are issued against the mail sever to determine if a mailbox exists for the email address. To protect against email harvesting, some mail servers will always return a positive response, saying a mailbox exists, when in fact, it doesn't. Also, a DNS Server or SMTP server may be down at the very instance you are attempting to validate an email address. Thus aspNetMX could accidentally mark that email address as not valid, when in fact it is. It's recommended that you test failed email addresses a couple of times, at different times, to verify they are in fact bad.
aspNetMX has been highly optimized, however, most of the time-intensive issues that affect email validation are outside of the control of aspNetMX. These include the across-the-internet or across-the-network DNS lookups, and the across-the-internet SMTP calls. Depending upon your network speed, and the remote SMTP server, the whole process may be completed in a few seconds, however, we've seen it take as long as 60 seconds. To help with this, aspNetMX utilizes a number of built-in higher-performance techniques.
Check out aspNetMX's High Performance Features.