Bug Fix 0.8.4, Mailing Lists, Spam Blocking

A few announcements from my work on Lamson the last few days. I managed to fix a bug, put Lamson to work doing Lamson’s mailing lists, and use Lamson to do some spam blocking on my own email account.

Hopefully eating my own dogfood won’t be too painful.

Grab 0.8.4, Important Bug Fix

I wasn’t using the SMTPServer class in Python correctly, and was stopping the whole server when a single channel had an error. It’s a one line fix and I’ve been running it for a few days with no problems.

Please make sure that you upgrade if you installed Lamson:

sudo easy_install —upgrade lamson

Or you can grab it from PyPI

Mailing Lists

Lamson is now running its very simple examples/mailinglist sample on lists.lamsonproject.org. You can send an email to:

lamson.users-subscribe@lists.lamsonproject.org

And try it out. The software running that is also what’s available in the examples/mailinglist sample (minus a few tweaks) so if you want to help make it a real functioning mailing list then feel free to contribute.

I’m subscribed there, and I’ll be working on it over the next week to turn it into a more complete and robust mailing list. An important thing I need to implement is bounce and vacation detection. I’ll probably also take my spam filter hacks and work them in as well.

Also, the software at lists.lamsonproject.org is an open mailing list system. Feel free to use it at your own risk, and if it becomes popular then I may turn it into a permanent thing.

As an open mailing list system, what it does is creates any list that doesn’t exist when you subscribe. Think of it as lazy loading for mailing lists. No need to fill out forms, beg for permission, alter aliases, edit text files, or run a ton of shell commands.

Just subscribe and go.

Now, if that turns into a massive abuse vector then I’ll turn it off, but I’d like to make it work for people since it demonstrates something simple that Lamson can do which other mailing list systems are bad at.

Spam Filtering And Graylists In The Works

My personal email account (zedshaw@zedshaw.com) is now running Spambayes inside of Lamson to filter spam. Here’s the code (stripped down for show):

class SpamHandler(server.MessageHandler):
    """Uses app.spam to mark all messages it receives as Spam."""
    def process(self, session, message, args):
        filter = spam.Filter()
        filter.train_spam(message.msg)
        filter.close()

class FilterHandler(server.MessageHandler):
    """
    Uses the spam filter to either queue up a message
    into the run/queue for later review, or forward 
    it on if it is not spam.
    """
    def process(self, session, message, args):
        classifier = spam.Filter( )
        classifier.filter(message.msg)
        if message.msg['X-Spambayes-Classification'].startswith('spam'):
            q = queue.Queue('run/spam')
            q.push(str(message))
        else:
            self.relay.deliver(message)

This shows Lamson’s raw “handler style” of extension, which the Finite State Machine stuff is built on. These are wired into the config/settings.py file routing so that any mail that’s sent to zedshaw@zedshaw.com goes through FilterHandler and any mail that sent to bogus addresses @zedshaw.com goes through SpamHandler.

It turns out that a lot of spam is delivered to random addresses at zedshaw.com, so this works as an autotraining mechanism. Well, at least until some asshat figures out he can game my spam filter.

The FilterHandler then takes messages that SpamBayes knows is spam and puts it into a queue for later review. I periodically check that folder and pull out any false positives for retraining.

It’s all very hacky right now, but seems to be working really well, so once I work out the full workflow I’ll formalize this code and add it to Lamson as extra handlers to use. I’ll also implement a simple graylisting system and include that too.

Well, enjoy the work so far and shoot me any comments you have.