Thursday, October 30, 2008

Mailfilter


Ever tried to do something advanced with procmail? I did. Enough pain to sit down and find something better.

So fire, who is a friend of mine, and I came together one afternoon to write Mailfilter. This enables you to do your mail filtering with Python.

I really like the result. Check out this few lines which automatically result in one folder for each mailinglist I am subscribed at.

@filter("List-Id", "(.*)$")
@filter("List-Post", "<mailto:(.+)>")
@filter("List-Id", "[^<]*<([^>]+)>")
def mailinglists(mo):
    return "ml." + esc(mo.group(1))

@filter("Mailing-List", "contact (.*)-help@(.*); run by ezmlm")
def ezmlm(mo):
    return "ml.%s-%s" %(esc(mo.group(1)), esc(mo.group(2)))

No comments:

Post a Comment