Procmail is a program for filtering electronic mail. It is very useful for pre-sorting and pre-processing large amounts of incoming mail. You can use it to sort out mail from mailing lists, to dispose of junk mail, to send automatic replies, or even to run a mailing list.
I am using it to classify incoming mail from the mailing lists that I am subscribed into folders, and when you are subscribed to a large amount of mailing lists it can be painful to write all the rules and you might end with a copy-paste-monkey-complex. So I wrote an small program in Python that will generate a .procmailrc file for your convenience. You must feed the program with your email address and the path to a file containing the mailing lists that you are subscribed to and the folder you want them to be delivered.
The file has the following format:
[folder1] email@example.com firstname.lastname@example.org [folder2] email@example.com firstname.lastname@example.org
A real example:
[debian-security] email@example.com firstname.lastname@example.org [networking] email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com firstname.lastname@example.org email@example.com [wireless] firstname.lastname@example.org email@example.com [filesystems] firstname.lastname@example.org email@example.com
And the program will generate a .procmailrc from the templates that are defined within it and output the file to stdout.
But this way I keep my subscriptions in easy-to-read-and-edit file and each time I change them I simply re-run procmailgen against it:
./procmailgen.py mailinglist-folders firstname.lastname@example.org >~/.procmailrc
You can download the code here. Hope that you will find it useful. Don’t forget to create the mail folders with your email client.
UPDATE 01-2011: Moved the code to a repository at github and added support for managing RSS Feeds with rss2email