procmail
[Top] [All Lists]

Re: doubled folders

1999-10-18 02:47:31
Alexander Langer <alex(_at_)cichlids(_dot_)com> writes:
Currently I use the following rule to filter my FreeBSD-Maillists:

:0
* ^TO_.*[
* <](freebsd-)?\/(security|isdn|ports|questions|current|announce|stable|
hackers)@freebsd.org
/home/alex/Mail/`echo $MATCH | sed -e 's/\([a-zA-Z]*\)@.*/\1/'`

But now, when, let's say, e.g. a msg is x-posted to hackers & current,
it only filters it to one list. Anyone has a effective idea to filter
it to both list-mboxes, without adding a rule for each list with :0c ?

You need to filter on a header added by the list software.  Which header
to use depends on your system and the list software.  With many systems
the Return-Path: header is works well.  If the list is run by SmartList
then the Resent-From: header is a good choice.  If you see a List-Id:
header then it would be an excellant choice as that's its purpose.

There's actually another way to do it: subscribe to each list with
a different address and then filter on the address used to get to
you.  This is generally done with sendmail's plus-addressing or the
hyphen equivalent provided by qmail: under sendmail 8, the address
user+foo(_at_)hostname is the same as user(_at_)hostname except that the data
between the plus and the at-sign is availible to the delivery agent
(and you can alias the addresses's separately).  If procmail is the
local delivery agent, the data is availble from the .procmailrc as $1.
This is usually copied to a named variable and then tested like this:

        ARG = $1
        :0
        * ARG ?? ^^procmail^^
        procmail

That would file e-mail sent to user+procmail(_at_)hostname to the user's
procmail folder.  So, if you subscribed to the freebsd security mailing
list with the address <alex+fb-security(_at_)cichlids(_dot_)com> and to the 
freebsd
isdn list with the address <alex+fb-isdn(_at_)cichlids(_dot_)com> and so on with
the other lists, you could then you the following recipe:

        ARGS = $1
        :0
        * ARGS ?? ^^fb-\/(security|isdn|ports|questions|current|\
                          announce|stable|hackers)^^
        $HOME/Mail/$MATCH


I have three other quick comments: the first is that you're almost
certainly misusing the ^TO_ token by putting ".*[ <]" after it.
It's expansion ends with "(.*[^-a-zA-Z0-9_.])?" so the job of matching
up to an address is already done for you.

The second is that it's a good habit to use $HOME instead of hardcoding
your home directory.

The last point is that you don't need to use sed to strip the @freebsd.org
from MATCH.  You can do it with a second match:

        :0
        * ^TO_(freebsd-)?\/(security|isdn|ports|questions|current|\
                        announce|stable|hackers)@freebsd.org
        * MATCH ?? ^^\/[^(_at_)]+
        $HOME/Mail/$MATCH


Philip Guenther

<Prev in Thread] Current Thread [Next in Thread>