Search code examples
emailcoldfusiontrackingcfmail

Automated database tracking of Undelivr email in ColdFusion?


Given there is a "FAILTO=''" option for cfmail, triggering an email to be sent to that email if the email didn't get delivered...

Is there a way to somehow assign an ID or tracking # to an email, store it in a database with that ID... then update the status of that email if it fails?

I'd like to track bouncebacks... preferably WITHOUT sending the FAILTO to a POP3 or IMAP and then checking it with cfimap...

Is there any alternate way of handling this?

Maybe an event gateway that is triggered upon email failure?

UPDATE: I've decided to take a different approach, utilizing the sendgrid API. I'm hoping that lends me with a few more tools than CF offers.


Solution

  • The short answer to your question is unfortunately no.

    A longer version with a possible solution: The failTo email address populates the return-path in the email header, this then 'should' be used by mail servers for bounce backs (however see - http://www.bennadel.com/blog/1899-GMail-Seems-To-Ignore-The-Return-Path-Header-Defined-By-The-CFMail-FailTo-Attribute.htm for an example where it doesn't)

    So you are going to need to monitor an Imap or pop account to see your mails, however you can set up an event gateway to monitor this, with detailed instructions here - http://www.alagad.com/documentation/imapGateway/ImapWatcher%20Gateway%20Documentation.pdf

    What you're left with is needing to identify which mail matches which bounceback, when I've done something similar in the past I used unique id's for the failTo email addresses at a domain I owned. If you set that up and then use your listener cfc to look for the id in the return-path.

    So your sending code would work along the lines of:

    • Generate unique id
    • Send mail
    • Add row to database with unique id

    Your listener.cfc would then need to inspect the email returned and if it finds the unique id update the row with whatever information that you're after.

    Hope that that at least helps even if you'll need to set up some other bits.