Processing email feedback loops for fun & profit, part 1
Warning: this blog post expects you to know your email envelope recipient from your 'To' header address. If you don't, here's a good primer.
The company I currently work for sends out periodic mailouts to paying customers of our site. We comply with the CAN-SPAM act and give people a simple way to unsubscribe from our mailings, but some people still mark them as spam. This is a problem, because when people do this from the webmail interface of some ISPs, it records this, and if there are enough spam markings, starts refusing all connections from our mail servers until they process our removal request.
Many of the larger US ISPs allow you to sign up for an email 'feedback loop' where they notify you whenever they detect a 'spam' mail coming from your nominated IPs. We decided to try and use these feedback loops to automatically unsubscribe people from our mailing lists when they mark us as spam. There are two advantages:
- We have a lower chance of getting unilaterally blocked by some ISPs,
- People who don't want our messages won't get them.
All we need to do is pass the feedback loop messages to a script, extract the recipient address and send an unsubscribe request to the relevant part of our website. Sounds simple, right? I should be able to write something up using Python and procmail in an hour. Unfortunately life is a little more complex.
The first stumbling block is that most (all?) feedback loops remove some information from their notification emails. Of the two I've played with so far (AOL & Comcast), both remove the destination address. They don't do it sloppily either: every reference to the destination address is replaced with <redacted>. How can you tell who the message was sent to? In our case, we decided to modify our mailouts. Now, the envelope sender address we use in our mailouts includes a UID we can use to identify the sender. Previously our 'Return-Path' header looked like this:
Return-Path: <blah@ourdomain.com>
Now it looks like:
Return-Path: <blah+UID@ourdomain.com>
So now the feedback loop emails we get are useful! Next post I'll describe the simple procedure of parsing feedback loop emails with Python. If you want to skip ahead, here's a hint.
Comment (0)Leave a Reply