Skip to Content

procmail magic: I am not afraid of lists anymore

posted 03 Jun 2007

Yesterday a number of list posts from lists I had forgotten to write a procmail rule for made their way into my inbox. I didn't like the idea of adding yet more cookie cutter rules to my ever expanding .procmailrc to fix the issue so, I went hunting for a better solution.

After searching for a bit I found jdub's procmail which got me most of the way there:

# MOST LISTS - Automagically handle lists
:0
* ^((List-Id|X-(Mailing-)?List):(.*[< ]\/[^>]*))
{
    LISTID=$MATCH

    :0:
    * LISTID ?? ^\/[^@\.]*
    ifup.$MATCH/

}

# MAJORDOMO - Automagically handle Majordomo lists
:0
* ^Sender:.*owner-[^@]+@[^@\+]+
* ^Sender:.*owner-\/[^@\+]+
{
    :0:
    ifup.$MATCH/
}

But, vger.kernel.org mailing lists have listname-owner instead of owner-listname so I wrote this:

# MAJORDOMO with inverse owner
:0
* ^Sender:.*-owner@[^@\+]+
* ^Sender:[     ]*\/[^@\+]+
{
    :0:
    ifup.`echo $MATCH | /bin/sed -e s/-owner//g`/
}

Does anyone know how to skip that sed call? I am not too terribly happy with it but it works.

Final result: 80 insertions, 116 deletions and it handles all of my lists- not just the ones that I remember to add. w00t

blog comments powered by Disqus

About

Brandon Philips by Mujtaba Ali

ifup.org is the weblog of Brandon Philips and contains excerpts from my code, work and play.

I write Linux software and work on the systems layer of Linux. In the last two years I have helped to organize Linux Plumbers Conf and Freedom HEC Taipei. It has been rewarding to bring together these communities to discuss current Linux issues.

Robotics is another passion and I had the opportunity to mentor a FIRST Robotics team in Portland recently too. I also continue to work with my friend Ron Jackson to build some neat USB devices for robotics.