D F
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
<cfloop>
<cfmail>
</cfmail>
</cfloop>
the best why to avoid an error with <cfmail> when it gets a bad email
is to use <cftry><cfcatch>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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>
<cfloop query = "emails"....>
<cfif REFind("^[a-zA-Z][\w\.-]*[
<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
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
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>
<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>