Link to home
Start Free TrialLog in
Avatar of D F
D FFlag for United States of America

asked on

Cfmail bad email error

Is
<cfloop>
<cfmail>
</cfmail>
</cfloop>
the best why to avoid an error with <cfmail> when it gets a bad email
Avatar of erikTsomik
erikTsomik
Flag of United States of America image

is to use <cftry><cfcatch>
ASKER CERTIFIED SOLUTION
Avatar of SidFishes
SidFishes
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of D F

ASKER

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
However, it will not help you if the email address is invalid
is Invalid i meant does not exist
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>
what if the email does not exist it may give an error that why you better of having <cftry><cfcatch
Avatar of D F

ASKER

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
I see
Avatar of D F

ASKER

 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>