This one has come up before, you can bet.

Short answer:  If you have not validated your addresses you cannot use
the query= attribute safely.

If you wrap cfmail in a try/catch block and just let it continue on if
it hits a bad address, then you'll never scrub your db.  What I do
looks like what you see below.

includes/inc_verify_addresses.cfm runs a 40-odd-step address test.
Far less efficient than a regex but it creates a list of messages that
describe everything wrong with the address.  This is an html-formatted
unordered list and is dumped into variables.failurelist.

Then the mail xmit is attempted.  If an error was found in the format
checker, the error is logged into a special db table dedicated to
collecting system errors (one error per record, the errmsg and bad
address goes into a long text field).

If the format checker missed something, then the try/catch block bats
cleanup and handles it.  Here again the error is logged in the same
fashion and the process is allowed to continue.

When done, the list of errors is collected and can be emailed
automatically to some responsible party.  Since this could be a
Hyoooge email its not a bad idea to create some other method of
viewing the error log if you're dealing with any kind of decent-sized
list.

HtH,

--
--Matt Robertson--
MSB Designs, Inc.
mysecretbase.com

<cfloop
query="MailRun">
<cfset variables.InclEmailAddr=MailRun.EmailAddr>
<cfinclude template="includes/inc_verify_addresses.cfm">
<cfif not Len(variables.FailureList)>
<cftry>
<cfmail
to="#MailRun.Email#"
    from="#my.Email#"
    subject="#my.Title#"
server="#my.lServer#"
type="HTML">
...blah blah blah...
</cfmail>
<cfcatch type="Any">
...log the error...
</cfcatch>
</cftry>
<cfelse>
...log the error...
</cfif>
</cfloop>
...report the error to the email inbox of your choice.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to