Lamson for bounce detection

So every other week Andy bugs me about using something new and shiny that he’s found. This week it was Lamson – actually this week it was Lamson again, but back to the point. It’s a mail server written entirely in python. I’m generally a bit sceptical of new mail servers, I like my mail servers like my crypto, old and battle tested rather than new and shiny. However Lamson has bounce detection built in, and since I’m currently trying to work out how to do that I figured I’d give it a go on the merit of at the very least being able to use the bounce detection module.

The point of this, is to handle emails coming in to a mailing list address. Not the sort of communal mailing list that I could be using Mailman for, but rather the corporate sort where we’re sending newsletters to people who’ve signed up sort. So we get bounces and unsubscribe requests and such in return. I want all of this handled inside our django web app where I’m going to be keeping our lists and sending our newsletters from. The problem is I need a way to get to these emails at my own pace (or rather the pace of some script that has django + database access overhead) without choking up the mail server.

So, the idea is this. We collect our mail as per usual with the main mail server (it’s going there regardless, can’t change that) then mail for the mailing list address gets forwarded to the Lamson mail server. Here’s the fun part, using Lamson’s neat bounce module I look for bounce like messages and if one is found I stuff a whole bunch of extra headers on the message detailing who it was about, what the diagnosis is, etc. All messages, bounces or no are then put into a Maildir mailbox, from there a django management command can periodically look for new messages in the mailbox and process them at whatever speed it’s capable of, keeping completely clear of the mail server itself.

The last trick is using a Variable Message Envelope Return Path (VERP) so that every message is returned to a unique variant of the mail list address based on the user it was sent to and the campaign that the email was part of. This should work even in those situations where people send unsubscribe messages from an address other than the one they receive the mail.

This entry was posted in Old site imports and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *