Hexillion
 

HexValidEmail concepts

"Validation" is an unfortunate term when applied to email addresses because it implies that a successful validation certifies an address as good. (By "good", we mean the address can get email delivered to the intended recipient.) In practice, the only way to ensure an address is good is to try sending some email with it. If you get a response from the recipient, the address is good. Unfortunately this technique is clumsy, slow, and requires the patience and cooperation of the recipient.

If you want a quick, independent validation procedure, you must accept that email addresses are like theories--they cannot be proved, only disproved. HexValidEmail provides the easiest and most thorough means of disproving email addresses without actually sending email. (We should have named it HexInvalidEmail, but that would have been too pessimistic. :)

How it works

HexValidEmail's functionality lies mainly in its Connection object. Connection has a Validate method that splits the validation procedure into three progressive levels--syntax, DNS, and SMTP--and lets you choose how far you want to go. Each level presents an additional opportunity for disproving the address at the cost of increasing delay and network usage:

Level Function Delay Network usage
Syntax Parses the address to ensure legal syntax Less than one millisecond. None
DNS All of the above, plus makes sure the domain exists and has an address for receiving email (as specified by MX or A records) A second or two. Default timeout is 10 seconds. Little
SMTP All of the above, plus contacts the domain's mail server and inquires about the recipient Tens of seconds. Default timeout is 60 seconds. Combined with the DNS timeout, this makes a worst case of 70 seconds. Some

Validate returns a value indicating the highest level it completed without running into an error. If the error conclusively disproved the email address, the return value is hexVeLevelBad.

Possible Validate return values:
0 hexVeLevelBad
1 hexVeLevelSyntax
2 hexVeLevelDns
3 hexVeLevelSmtp

Two quick points:

  1. Not all errors disprove an address--a temporary network outage doesn't mean an address is bad, for example. If Validate likes the syntax of an address but can't connect to the network, it will return hexVeLevelSyntax, and the Error property will contain something like hexVeErrTimedOut.
  2. The return values are in numeric order, so the return from Validate effectively serves as a confidence rating for the address.

More about interpreting results...

A simple example

Let's look at a basic ASP/VBScript usage which may be all you ever need:

Const hexVeLevelDns = 2
Dim
oVE, iRating
Set oVE = Server.CreateObject( _
          "HexValidEmail.Connection")

oVE.FromDomain = "YourDomain.com"
oVE.FromEmail = "ResponsiblePerson@YourDomain.com"

iRating = oVE.Validate("test@example.com", _
                       hexVeLevelDns)

If hexVeLevelBad = iRating Then
    Response.Write "Address is bad"
Else
    Response.Write "Address appears good"
End If

The lines setting the FromDomain and FromEmail properties are part of using HexValidEmail politely.

Notice that we asked to validate to the DNS level but accepted any non-bad response. If the network isn't available for checking the domain, should a syntactically correct address still pass? The choice is up to you. This example would pass it. Asking for DNS-level validation still has value in this case because it offers a chance to discover that the domain doesn't exist or can't receive email.

Inputs and outputs

For such a simple concept, the HexValidEmail Connection object may seem to expose a lot of properties. Most of these are not necessary for basic operation, however--they just add value if you need it. Here's a summary:

Inputs
FromDomain Your domain for use with SMTP
FromEmail Your email address for SMTP
Options Modifies validation behaviors
Timeouts Lets you choose how long to wait
   
Outputs
general: Error Error value from Validate
from Syntax: Domain Domain from the address
ExtraText Comments, etc from the address
LocalPart Address part in front of the @
from DNS: MxRecs Collection of mail server info
from SMTP: SmtpSession Transcript of SMTP session

Before you get started

Be sure to read how to use HexValidEmail politely if you plan to use SMTP-level validation.

Show site map

contact us    privacy policy    legal information