Skip to main content
Inspiring
February 24, 2010
Question

Script to detect hard and soft mail bounces

  • February 24, 2010
  • 3 replies
  • 3878 views

Hi

I have a client that sends out mail to 25000+ people per day.

HE gets a large amount of bounces.

I need to delete hard bounces and capture soft bounces in a table.

I have got so far as to check the body of all bounce backs for all email addresses within the body.

How do i know detect if it is a hard or a soft bounce.

Please can someone assist me as my server is taking sever strain!

Best regards

Delon

<!-------------HERE IS MY CODE SO FAR------>

<cfpop
  server = "x"
  username = "failto@x.co.za"
  password = "x"
  action="getall"
  name = "somequery" timeout="90000">
 
  Failed mail:<Br><Br>
  <cfoutput query="somequery">
  #Currentrow#.  From: #From# -- Subject: #Subject#<Br>
 
  <CFSET text = "#body#">

<CFSET emaillist = "">
<CFSET start = 1>
<CFSET regex = "[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*\.(([a-z]{2,3})|(aero|coop|info|museum|name))">

<CFLOOP condition="start lt LEN(text)">
      <CFSET findemail = REFindNoCase(regex,text,start,"TRUE")>
      <CFIF findemail.len[1] AND findemail.pos[1]>
            <CFSET emaillist = LISTAPPEND(emaillist,MID(text,findemail.pos[1],findemail.len[1]))>
            <CFSET start = findemail.pos[1] + findemail.len[1]>
      <CFELSE>
            <CFBREAK>
      </cfif>
</cfloop>
<font face="Arial, Helvetica, sans-serif" size="1" color="##666666">#paragraphformat(body)#</font>
<font face="Arial, Helvetica, sans-serif" size="1" color="##FF0000">Emails Found: #emaillist#<br><Br><Br></font></cfoutput>

This topic has been closed for replies.

3 replies

February 25, 2010

FYI: Just came across this, while looking for something else:

http://bouncedetector.riaforge.org/

Inspiring
February 25, 2010

Great.

Will take a look shortly.

Thank you!

Inspiring
February 24, 2010

For starters, read RFC 2822 for the meaning of SMTP error codes. Then build on top of that to capture some string like "out of office" and treat them specifically.

February 24, 2010

Thats the wrong RFC, http://www.ietf.org/rfc/rfc1893.txt

Sadly this will be really unreliable though,a nd this is what I meant between NDR standards (from the RFC doc) and reality.

Not every writes "out of office" in their auto reply, and not every one uses english.  Then the SMTP return codes in the NDR are not always formatted the same, and sometimes they are wrong.

I have even seen NDR's were the sysadmins have had some fun, and written very amusing message to accompany the return codes.

Inspiring
February 24, 2010

I have a PDF which i found on the net with most SMTP Hard bounce error codes.

Here is the PDF

If i used all the error codes in my expression and searched for instances of them in my string, would that not be a good start?

If i created a decent list with all SMTP "hard bounce" error codes.

Thanks

Delon

February 24, 2010

Detecting the hard and soft bounce is actually really hard to do accurately.  Unless you have ALOT of time, I wouldn't even bother trying to do this yourself.

The problem is Email NDR standards vs reality.  The NDR messages that email servers send back can be very different from one another.

If you really really have to tell the difference then I would look at some third party products. EG http://www.listnanny.net

Even then I have found that some email servers even lie in the NDR message.  Like returning, no such email address, mailbox full, when it thinks your mail is spam even though it delivers the email successfully.

Hope this helps and good luck, email addy cleaning and NDR parsing is annoying.

Inspiring
February 24, 2010

Hi

Thanks for the post.

Ok my client needs me to filter through his email account (using CFPOP) and delete all hard bounces.

Do you know of any decent CF solutions?

Thanks a mil

Delon

February 24, 2010

Hi

No sadly I dont know of any Coldfusion based NDR parsing solutions.  Anyone else?  Don't forget though you can use .net libs in CF.

There are a few email delivery solutions out there though, which can help take care of bounce management.  I looked at these a while a go, one that I can still remember is http://www.zrinity.com/xms/

I ended up going with the .NET solution because it was more of what I was after.

One tip though, set up a seperate email address for bounces, and use the failto address attribute.  You can then collect all your bounces in one place.

Another good tatic is the sender address. Generate a UUID for every email you send, and use this as the sender email address name, or hide it in the message somewhere.  Then you can identify these UUID's in emails that get bounced back, and know exactly which email it was.

Cheers