Checking Email and DNS MX records in ColdFusion with Java DnsContextFactory and Google Public DNS
Nice short function using Google's DNS and Java DnsContextFactory. Based on a script I saw here Note; a trailing space fails here; so make sure that doesn't waste some time of your day when validating. <cffunction name="validateEmailAndMXRecord" returntype="Struct"> <cfargument name="emailAddress" required="true"> <cfargument name="checkMXRecord" required="false" default="true"> <cfscript> var env = CreateObject("java", "java.util.Hashtable"); var dirContext = CreateObject("java", "javax.naming.directory.InitialDirContext"); var type = ArrayNew(1); var attributes = ""; var atribEnum = ""; var stReturn = StructNew(); </cfscript> <cfif isvalid("email", arguments.emailAddress)><!--- basic validation (possibly not good...