The classic procmail recipe for (reasonably) safe automatic mailing list filtering is

* ^List-Id:[^<]+<\/[a-z0-9-.]+

This relies on mailing lists being configured such that the first part of the ID, up to the first dot, is a good identifier for the list. this is not always the case (*, I'm looking at you). Removing the dot from the expression above means you end up with unambiguous, albeit long, folder names (

If you access this mail over IMAP, you have another problem: the dots create a nested folder heirarchy that probably doesn't make any sense (devellistsfedoraprojectorg). It's possible to change the configuration of IMAP clients and servers to use a different delimiter, but this is not an oft travelled road, and I don't feel like finding the pot holes. Better to substitute the dot for something else. I'd recommend an ASCII character, Unicode seems to throw up a whole bunch of client problems.

Here's a variation that solves the problem:

* ^List-Id:[^<]+<\/[a-z0-9-.]+
  subst=| echo "$MATCH" | tr . :


At the cost of elegance, you can add rules to give friendlier names to lists from folks who have well-defined list-ids (integration left as an exercise to the reader):

* ^List-Id:.*debian.*lists\.debian\.org
subst=| echo "$MATCH" | sed 's/\([A-Za-z0-9-]\+\)\..*/\1/'

Finally, there are some "lists" you probably don't want to file in their own individual folders. Inject these into the top-most rule:

* ! ^List-Id.*groups\.facebook\.com

Finally thanks to Brett for showing me some exim filter snippets that would let me implement the above in a (slightly) nicer looking way. Sadly I think I'm stuck with procmail for some other features I use, but it's been a while since I looked.


comment 1

FWIW: on Macintosh is colon the directory separator.

IOW: the / is on Mac a :

Comment by Stappers,