4 Replies Latest reply on Sep 26, 2006 12:33 PM by MikerRoo

    Weed out email returns

    jeremy@noble
      I'm managing an email list with out 14,000 active users. It's an online weekly contest that runs with CF. Twice a week we send out an email to all the users using CFMAIL. It actually works, but usually about 2000 or so get returned since they are no longer valid emails. Is there any way to have CF look through all those email returns and automatically de-activate them from our database? Thanks! We use Microsoft SQL Server.

      PS. I've used a custom tag to make sure all the emails are syntactically correct. The returns are all just bad email addresses.
        • 1. Re: Weed out email returns
          MikerRoo Level 1
          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):

          <cftry>
          <!--- send your mail, don't forget to turn OFF spooling if you want this to work--->
          <cfcatch type="Any">
          <cfif cfcatch.detail contains "javax.mail.SendFailedException">
          <cfset invalidAddresses="">
          <cfloop index="i" from="1" to="#arrayLen(cfcatch.rootCause.InvalidAddresses)#">
          <cfset invalidAddresses=listAppend(invalidAddresses,cfcat ch.rootCause.InvalidAddresses .toString())>
          </cfloop>
          </cfif>
          </cfcatch>
          </cftry>

          <cfdump var="#InvalidAddresses#">
          • 2. Re: Weed out email returns
            jeremy@noble Level 1
            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?
            • 3. Re: Weed out email returns
              Wilgeno_wnt Level 1
              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.
              • 4. Re: Weed out email returns
                MikerRoo Level 1
                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.