Cfmail bad email error

Is
<cfloop>
<cfmail>
</cfmail>
</cfloop>
the best why to avoid an error with <cfmail> when it gets a bad email
overcolorAsked:
Who is Participating?
 
erikTsomikSystem Architect, CF programmer Commented:
is to use <cftry><cfcatch>
0
 
overcolorAuthor Commented:
I like Bens post. I just wanted to build a code that even if there is a bad email it will pass it and keep processing the rest
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
erikTsomikSystem Architect, CF programmer Commented:
However, it will not help you if the email address is invalid
0
 
erikTsomikSystem Architect, CF programmer Commented:
is Invalid i meant does not exist
0
 
SidFishesCommented:
to not send a malformed email something like this should work



<cfloop query = "emails"....>
<cfif REFind("^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$", emails.email)>
<cfmail...>
<cfelse>
skip
</cfif>
</cfloop>
0
 
erikTsomikSystem Architect, CF programmer Commented:
what if the email does not exist it may give an error that why you better of having <cftry><cfcatch
0
 
overcolorAuthor Commented:
erikTsomik I just dont want cfmail to error out, i dont care if the email really exist. I understand that sometimes people cancel there email accounts
0
 
erikTsomikSystem Architect, CF programmer Commented:
I see
0
 
overcolorAuthor Commented:
 I got it, I use this code to find the bad emails then deleted them. Then ill use my loop to send

   <cfquery name="getlist" datasource="#dns3#">
SELECT id, email
FROM _information
ORDER BY email ASC
              </cfquery>
                 
                 
                <cfoutput query="getlist">
                  <cfset address = "#email#">
                  <cfif isValid("email", address) eq False>
                    #email#<br>
                  </cfif>
                </cfoutput>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.