-
-
Save ivanionut/3b419afe55ec7b15a70b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
/* Copy IsEMail.jar to java path. Download from https://code.google.com/p/isemail/downloads/list */ | |
emails = ["[email protected]", | |
"[email protected]", | |
"[email protected]", | |
"""much.more unusual""@example.com", | |
"[email protected](comment)", | |
"""first\last""@iana.org", | |
"first.last@com", | |
"""Joe.\Blow""@iana.org", | |
"[email protected]", | |
"[email protected]", | |
"[email protected]", | |
"first.last@x234567890123456789012345678901234567890123456789012345678901234.iana.org"]; | |
/* Set DNS server to prevent ColdFusion error: | |
javax.naming.ConfigurationException: localhost:2932 is not a valid DNS pseudo-URL */ | |
sys = createObject("java", "java.lang.System"); | |
sys.setProperty("java.naming.provider.url","dns:/YOUR_DNS_SERVER"); | |
isEmailObj = CreateObject("java", "com.dominicsayers.isemail.IsEMail"); | |
check_DNS = true; | |
responseLabels = ListToArray("Email,isValid,Status,Rule ID,Rule Name,SMTP SMTP Code"); | |
function checkEmail(e, useDNS){ | |
var check = isEmailObj.is_email_verbose(e, Check_DNS); | |
var response = structNew(); | |
response["Email"] = e; | |
response["isValid"] = check.getState().isValid(); | |
response["Status"] = check.getStatusTextExplanatory(); | |
response["Rule ID"] = check.getId(); | |
response["Rule Name"] = check.getConstantName(); | |
response["SMTP"] = "N/A"; | |
response["SMTP Code"] = "N/A"; | |
if (useDNS){ | |
response["SMTP"] = check.getSmtpCode(); | |
response["SMTP Code"] = check.getSmtpCodeText(); | |
} | |
return response; | |
} | |
for(i=1; i LTE ArrayLen(emails); i=i+1){ | |
writeoutput('<h2>#emails[i]#</h2>'); | |
temp = checkEmail(emails[i], check_DNS); | |
for(a=1; a LTE ArrayLen(responseLabels); a=a+1){ | |
if (StructKeyExists(temp, responseLabels[a])){ | |
writeoutput('<div><b>#responseLabels[a]#:</b> #Temp[responseLabels[a]]#</div>'); | |
} | |
} | |
writeoutput('<hr>'); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment