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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CFMAIL Email address validations

Status
Not open for further replies.

jl8789

MIS
May 22, 2003
293
0
0
US
Question, is it absolutely necessary to validate the email addresses before including them in my to when using cfmail?

I can use my outlook and have a bunch of addresses in the to line. All the valid email addresses get the email and the invlaid email addresses don't. With the CFMAIL tag, if 1 invalid address is in the to line, it will NOT send out the email to anyone.

Do I have to validate each email address before including them in the CFMAIL, or is there another way?

THANK YOU!
 
jl8789, well, validating e-mail addresses is always good coding practice. I'd say a big profound YES to that.

How are you populating the e-mail addresses in the <cfmail> tag? Is it coming from the dB via a query? Is it coming from the user (like 'send this page to a friend' feature)? Or, is it coming from an outside source (like a tab-delimited file)? In any case, you should loop over the e-mail addresses and check it against an e-mail validation script and ones that don't adhere to the syntax scrub them out.

I can post the e-mail validation code I use tonight when I go home. But cflib.org has some good ones (or you can google e-mail validation script).

____________________________________
Just Imagine.
 
Thanks. I'm putting a list of addresses in the TO line, usually from a query. Either way, the email address has to actually exist and be valid, not just only be syntactically correct.
 
I have to rely on user entered email addresses for some processes I run, and in those cases I use:
Code:
<cftry>
  <cfmail......>
<cfcatch>
  <!---- record who this is being sent to who is sending date and time --->
</cfcatch>
</cftry>
 
By the way, the way I use cfmail, its executed in a loop. For my purposes I need to send the email to one person at a time.
 
actually exist and be valid

I don't know if there really is a pure-definite way to check that. With so many different type of e-mail addresses and domains they can originate from that'd be quite a task.



____________________________________
Just Imagine.
 
Just to add my 10p to the discussion. We used this tag ( validating emails. It is built on java classes and is quite good. This can check the syntax, MX record, the domain and some other stuff. I wouldn't recommend using it within a loop though as it is quite slow. If you want to check the syntax then Ben Forta wrote a good email regular expression, but for the life of me I can't find the code or the article on his site at the moment

Tony
 
This problem can easily be overcome by setting the smtp sendpartial property to true in the JVM Arguments in the CF server settting. This way, if any 'bad' addresses are in the list, they will simply be ignored and the rest of the valid addresses receive the email.

-Dmail.smtp.sendpartial=true
 
If you are using MX7, you can use the IsValid function

<cfif isValid("email", myQuery.email_addy)>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top