LamsonProject: Lamson The Python Mail Server

#

## Features

- Avoid aliases forever! Lamson uses friendly regular expressions and FSM-based routing.

- Use an RDBMS and ORM instead of a bizarre combination of flat-files and hashtables!

- Get up and running quickly. Lamson can be installed and running in 30 seconds.

Get Started »

## The Python SMTP Server

We've all been there, mucking around in the sendmail m4 macros trying one more time to get the damn mailing list to update for the new users. Every time we say, "This sucks, I want to rewrite this stupid thing." Yet, when we're done, we simply crawl back to our caves covered in our sendmail wounds.

Lamson's goal is to put an end to the hell that is "e-mail application development". Rather than stay stuck in the 1970s, Lamson adopts modern web application framework design and uses a proven scripting language (Python).

# Lamson The Python Mail Server

Rather than stay stuck in the 1970's, Lamson adopts modern web application framework design and uses a proven scripting language (Python).

    @route("(post_name)@(host)")
    def START(message, post_name=None, host=None):
        message['X-Post-Name'] = post_name
        confirmation.send(relay, "post", message, "mail/confirm.msg", locals())
        return CONFIRMING

Instead of hideous aliases files (that you never remember to update) Lamson uses friendly regular expressions and routing decorators that make configuring how email is handled trivial.

    @route("post-confirm-(id_number)@(host)", id_number="[a-z0-9]+")
    def CONFIRMING(message, id_number=None, host=None):
        original = confirmation.verify(message, id_number)
        ...

    @route("(post_name)@(host)")
    @route("(post_name)-(action)@(host)", action="delete")
    def POSTING(message, post_name=None, host=None, action=None):
        name, address = parseaddr(message['from'])
        ...

Rather than bizarre flat file "databases" and hashtable stores, Lamson uses anything that Python does to store data. You can use all of the following to store data in Lamson:

- Django's ORM
- web.py's simple database library
- Tokyo Tyrant
- Lightcloud
- Python's Shelve (not recommended)
- Raw SQLite3
- SQLObject
- CouchDB
- Mongo DB
- SQLAlchemy

There's so many great ways to store data in Python that Lamson doesn't make any assumptions other than to provide a convenience function or two for configuring SQLAlchemy (since it's kind of a pain to setup). In reality, there's so many ORMs and storage mechanisms available to Python that you should try as many as you can and use the one you like the most.

Lamson also supports extensive spam blocking through SpamBayes:

    @route("(anything)@(host)", anything=".+", host=".+")
    @spam_filter(ham_db, "tests/.hammierc", "run/queue", next_state=SPAMMING)
    def START(message, **kw):
        ....

Bounce detection and analysis is available that regular people can use without going RFC nuts:

    @route("(anything)@(host)", anything=".+", host=".+")
    @bounce_to(soft=SOFT_BOUNCED, hard=HARD_BOUNCED)
    def START(message, **kw):
        ...

All within a framework that works well with existing legacy mail servers so you can gradually get into using Lamson.

## The 30 Second Introduction

If you have Python and easy_install already, then try this out:

    $ easy_install lamson
    $ lamson gen -project mymailserver
    $ cd mymailserver
    $ lamson start
    $ lamson log
    $ nosetests
    $ lamson help -for send
    $ lamson send -sender me@mydomain.com -to test@test.com \
            -subject "My test." -body "Hi there." -port 8823
    $ less logs/lamson.log
    $ mutt -F muttrc
    $ lamson stop -ALL run

You now have a working base Lamson setup ready for you to work on with everything you need installed.

## Next Steps

Grab the code and you can read through the quick start documentation. After you've gone through that, best thing to do is read the code to the examples/osb example included in the source distribution and read the rest of the documentation on this site.

At any point, you can get help for all available Lamson commands with:

    $ lamson help

You can get individual command help with:

    $ lamson help -for start

Finally, if you really want to get started using Lamson to implement your dream email application, but are completely lost, then you can contact me for help.