I personally can't see a way to do this, but I'm hoping there could be a clever hack to make it work.
We have to send out regular emails to customers, many of who's emails expire and give us a mail delivery failure. To keep the database accurate and clean, I'd like to delete their record from the database when an email fails to be sent to them.
So currently it goes a little something like this:
<cfloop query="rsCustomers">
<cftry>
<cfmail to="rsCustomers.Email" from="us@ourcompany.com" failto="fails@ourcompany.com" subject="Whatever">
[email text here]
</cfmail>
<cfcatch type="any">
<!--- just to skip this record when it fails to send --->
</cfcatch>
</cftry>
</cfloop>
I could run a query within the catch area to delete records when there was an error in the record (e.g. malformed email address). But nothing happens when the mail is undeliverable. I get a failure notice to my inbox but these can be in the hundreds so its difficult to manually go through and delete from the database.
Is there anyway to "catch" the failed to send emails and then feed them back in to a query to delete from the database?
Someone once did a presentation on this at a function I attended. The approach was:
The presenter ran this file as a scheduled job.