Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email Validation

Status
Not open for further replies.

boatguy

Programmer
Oct 22, 2001
153
US
Hi!

Is there a way in CF to either validate the an email address posted in a form submission is valid or at the minimum validate that the domian exists? I am aware of an ASP solution, but can't find anything around doing the check in CF.

Thanks.
 
This works for me:
Code:
<!--- VALIDATES EMAIL ADDRESS TO MAKE SURE ITS SYNTAX IS VALID --->
<cfscript>
  function isEmail(str) {
    return REFindNoCase("^['_a-z0-9-]+(\.['_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name|jobs|travel))$", str) IS 1;
  }
</cfscript>

<cfif #YesNoFormat(isEmail('FORM.Email'))# is 0>
  <!--- EMAIL VALIDATE FAILED.  STATUS=9 INVALID EMAIL ADDRESS ENTERED. --->
  <cflocation url="errorPage.cfm?Status=NpEmail" addtoken="no">	
</cfif>

Place the above in the action page. It will check to see if the email from the form matches that of the cfscript.

____________________________________
Just Imagine.
 
Thanks for the input, I was not clear in my original post. I actually want to ping the users mail server to check if the address exists. What I meant by at a minimum is, check to see if the users domain exists. Is this posible?
 
Is this for signup / registrations?

If so just email the user a registration link that would have to be clicked on, that contains a url variable identifier to activate the account.

If not...
I'll dig deeper.


Kevin
 
No, it's for a lead management system that I have developed. Basically, the user requests to have a dealer contact them, we identify the closest dealership and send the contact request to the dealer. The dealers are now asking that we verify that the email address is correct before we send the request to them.
 
this is the solution that we have used in the past - - it will check that the address is syntactically valid, check the mx record, check the top level domain and will ping the mail server as well.

Works quite reliabily, if you are going to loop over a lot of email addresses then we found this can be quite slow, but other than that works as intended.

Hope this helps!

Tony
 
Thanks DV,

I found that yesterday morning, purchased and installed it and you are right it does soom to wotk well.

Thanks again to everyone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top