"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:
||Parses the address to ensure legal syntax
||Less than one millisecond.
||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.
||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.
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:
Two quick points:
- 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.
- The return values are in numeric order, so the return from Validate
effectively serves as a confidence rating for the address.
More about interpreting
A simple example
Let's look at a basic ASP/VBScript usage which may be all you ever need:
Const hexVeLevelDns =
Dim oVE, iRating
Set oVE = Server.CreateObject( _
oVE.FromDomain = "YourDomain.com"
oVE.FromEmail = "ResponsiblePerson@YourDomain.com"
iRating = oVE.Validate("email@example.com", _
If hexVeLevelBad = iRating Then
Response.Write "Address is bad"
Response.Write "Address appears good"
The lines setting the FromDomain
properties are part of using HexValidEmail
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:
||Your domain for use with SMTP
||Your email address for SMTP
||Modifies validation behaviors
||Lets you choose how long to wait
||Error value from Validate
||Domain from the address
||Comments, etc from the address
||Address part in front of the @
||Collection of mail server info
||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.