maildirproc

maildirproc is a program that processes one or several existing mail boxes in the maildir format. It is primarily focused on mail sorting — i.e., moving, copying, forwarding and deleting mail according to a set of rules. It can be seen as an alternative to procmail, but instead of being a delivery agent (which wants to be part of the delivery chain), maildirproc only processes already delivered mail. And that's a feature, not a bug.

maildirproc was written by Joel Rosdahl <joel@rosdahl.net> and is distributed under the terms of the GNU General Public Licence.

Benefits

So, what's good about using maildirproc instead of a more conventional setup, with a delivery agent like procmail? For me (the author) it's this:

Download

Version 1.0, released 2014-12-13 (see NEWS for a list of changes):

Source code repository

Background

For a long time, I used procmail to sort my mail, but I was not entirely happy with its configuration language. I subscribe to a lot of mailing lists and I use several e-mail addresses, so the .procmailrc file was quite large and complex and I found it hard to express mail sorting rules elegantly. I wanted to be able to define and use functions, data structures, if statements, loops and other imperative language constructs and felt that procmail's rule-based vocabulary was limiting. I thought about writing a program to generate the configuration from some higher-level rules, but I never got to it. I also didn't feel comfortable with e-mail sorting being part of the delivery chain. (Granted, procmail can be used in other setups too.)

Then one day I stumbled upon a program called Maildird, written by Jörgen Cederlöf, and I liked its basic design:

"Maildird calmly waits until the mail is delivered, notices that a new mail has arrived in the Maildir it monitors, writes something useful in the log [...] and moves the mail safely to the correct Maildir."

Since Maildird was not configurable (at least not at the time) in the way I wanted, I decided to write my own program that worked somewhat similarly but with a configuration style that suited me. If you like it, you are welcome to use (or improve) it too.

Documentation

See the maildirproc reference.

Examples

See the examples directory.

Installation

maildirproc has no other dependencies than a working Python on a Unixish system. No special installation is needed; just copy the maildirproc file to a suitable place and run it. You can also run run python setup.py install.

You can run maildirproc in several diffent ways, e.g.: