Not yet rated
Tags:



Problem

Despite the range of regular expressions designed to validate email addresses and the well established verification technique of sending an email with a unique verification key in the URL I had a requirement to automatically and silently (i.e. without the end user knowing) validate a list of email addresses.

Solution

Mail Verification (or Mail Verify as you'll find it referred to in other languages) is a technique which takes advantage of the triplet section of SMTP in order to verify if a server will actually accept mail for a given user. ColdFusion lacks a number of basic tools to work with SMTP at a low level but is more than able to lever the power of Java to do the heavy lifting.

Detailed explanation

The CFC in the attached ZIP contains code that will perform a low level verification of an email address by completing an SMTP transaction up to the RCPT TO command. This is normally the point at which an MTA will reject mail based on recipient.

Of course before we can actually test an email we need to get the list of MX servers who are responsible for mail for the domain of that address.

The CFC also contains an MX lookup tool that takes a domain and uses the Java jndi classes to return the results of an MX DNS query.

Finally there is a CFM in the attached ZIP that shows the (very basic) usage of the component.

Please note: Mail Verify is not foolproof. Some would even consider it to be bad practice and it should certainly not be relied upon for everyday verification where other techniques will be more reliable. That said, for mass verification, it is a useful tool to have in your arsenal.

mailvrfy.zip

mailvrfy.zip
[MailVrfy.zip]

+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes