Lamson project takes pain out of email

25.12.2009
Dealing with email looks simple in theory, but becomes more and more complex the more you look at it. Postel's Law — be conservative in what you do; be liberal in what you accept from others — seems to have been ignored by many when it comes to email.

Many implementations seemingly only follow parts of the specifications. At the same time, tools for developers who need to interface with email haven't really changed in the last 10-15 years. The result: People making the same mistakes again and again.

This is where the Lamson project comes in. It's written by Zed Shaw, author of the Mongrel server made famous by Ruby on Rails. Lamson's design is model view controller (MVC) based, making it very similar to the newer web frameworks popular with developers these days, such as Ruby on Rails and Django.

The standard setup involves having one of the standard mail servers in charge of basic sending and receiving of emails and letting Lamson deal with the content and destination.

Coding in Lamson is actually quite simple. Begin by creating a new handler and coding up some behaviour for it. Handlers start by defining the route that they match and finish by returning a state.

A regular expression is used in the config file to define what parts, such as listname or host, should look like. This makes for routes that are easier to maintain than giant regular expressions.