This content has been marked as final. Show 4 replies
You can read and parse the mail.log file.
Or if you are willing to turn off he spooler then you can wrap the cfmail call in a try-catch like so (Paul H's code):
<!--- send your mail, don't forget to turn OFF spooling if you want this to work--->
<cfif cfcatch.detail contains "javax.mail.SendFailedException">
<cfloop index="i" from="1" to="#arrayLen(cfcatch.rootCause.InvalidAddresses)#">
<cfset invalidAddresses=listAppend(invalidAddresses,cfcat ch.rootCause.InvalidAddresses .toString())>
Thanks for the tip! Unfortunately, I can't turn off the spooler as I'm on a shared server. How would I go about parsing the mail.log file?
Another possiblity is to have a dedicated "from" address that will receive the bounce backs then use cfpop to check that mailbox and search the message for various possible strings like 'email address invalid' or 'address not found' and remove them from your mailing list.
The cfpop suggestion is good if you don't mind wading through all the spam you will eventually get.
Attached is sample code to parse the log file.
Please note that it is highly dependent on your mail server settings to report errors.