-
1. Re: CFMAIL error when encountering bad address
Dan Bracuk Dec 10, 2012 2:39 PM (in response to sakonnetweb)ColdFusion has an isValid tag that can be used to ensure the address has the proper structure. Ensuring that it represents an actual email address is something else altogether.
-
2. Re: CFMAIL error when encountering bad address
Adam Cameron. Dec 11, 2012 1:27 AM (in response to sakonnetweb)I try to ensure their email going in the DB is validated via javascript- but this not totally effective.
One should never rely solely on client-side validation for this sort of thing, as it can be defeated reasonably easily. Your validation should alwyas first and foremost be on the server side where you can guarantee it will run, client-side validation should be considered more UI sugar than actual validation.
That said, if you have junk data in your DB, you need to do what Dan suggests: validate the data and report back on which data is bung. I would not do this at the time you come to be sending the email I'd do it as an exercise immediately after fixing your validation so it's done server side, so that the data in your DB is all valid.
--
Adam
-
3. Re: CFMAIL error when encountering bad address
BKBK Dec 11, 2012 2:13 AM (in response to sakonnetweb)You may have to validate the e-mails one by one. You could loop through the e-mail addresses, and do something like
<cfloop>
<cfset isFromEmailValid = isValid("email", fromEmail)>
<cfset isToEmailValid = isValid("email", toEmail)>
<cfset isSubjectValid = len(trim(subject))>
<cfif isFromEmailValid and isToEmailValid and isSubjectValid>
<cfmail from="#fromEmail#" to="#toEmail#" subject="#subject#"></cfmail>
<cfelse>
<!--- log details of unsent mail--->
</cfif>
</cfloop>
However, as you can easily guess, this method is unsuitable for large e-mail jobs
[Edited: my initial response had crossed Adam's on the wire.]

