procmail
[Top] [All Lists]

Re: Catch-all list filter

2008-01-03 12:45:33
N.J. Mann wrote:
Hi,


In message <477C179E(_dot_)4050504(_at_)dd-b(_dot_)net>,
      David Dyer-Bennet (dd-b(_at_)dd-b(_dot_)net) wrote:
  
I'm trying to write a catch-all filter that will use the information in 
the List-ID: header to automatically make a folder for lists that show 
up in my inbox.  (Yeah, I know some spam might either accidentally or 
intentionally have such a header; this comes after my anti-spam stuff so 
I don't care too much.)  And yeah, some lists don't have that header, 
but this will automate much of the list folder creation process for me, 
and I'll feel less bad about handling the exceptions manually.  And if I 
find common exception cases, I can automate them some other way.

Anyway, what I'm trying so far is:


    :0
    * ^List-Id: \/.*$
    {
        gname=` echo $MATCH | tr -d '<>' | tr -t '. /' '_' `
        LOG="gname $gname
    "
    

You have already had a action for this recipe, so you need to start a
new recipe before your second action.

          :0
  
        .Auto.$gname/
    }
    

Either an assignment isn't an action line, in which case ".Auto.$gname/" 
is the first action line in that recipe, or else I've already had *two* 
action lines (the two assignments, both of which worked).   So that 
can't be the explanation.

I haven't tested yet, but I'm perfectly willing to believe you've 
pinpointed the *problem* (and your solution will no doubt work).  But 
the explanation is internally inconsistent, so it doesn't help me 
*understand* yet, and avoid such mistakes in the future.  I'm poking at 
the man pages to see if I can get the details straight in my head, with 
the right names attached (I keep calling things the wrong names thinking 
about these bits, which partly explains my confusion), but I wanted to 
get a response out rather than just leaving your useful suggestion 
sitting there.

Anyway, thank you! 

Your echo/tr/tr system may work, but an all procmail solution may be
better.  There have been a number of solutions to the "filing list mail"
problem posted to this list in the past so it is worth searching the
archives.  My own solution is as follows:

    :0
    * 9876543210^0 ^List-Id:.*<?\/[a-z0-9_-]+[.]
    * 9876543210^0 ^List-Post:.*<?\/[a-z0-9-]+[(_at_)]
    * 9876543210^0 ^Delivered-To:.*<?\/[a-z0-9-]+[(_at_)]
    {
        :0
        * MATCH ?? ^^\/[a-z0-9_-]+
        { LISTNAME = $MATCH }

        # special processing for mailman messages (e.g. monthly
        # subscription reminders) removed from here to simplify example

        :0
        $LISTNAME/
    }

This handles all but one of the over fifty mailing lists I receive mail
from.
  

I was unhappy about the cpu cost of forking the multiple external 
programs (though...it's not my cpu :-)).  So looking at some 
alternatives is definitely something I'm interested in.   I was thinking 
of writing an external program to do more precisely what I wanted, but a 
pure-procmail solution that does something good enough may be the way to 
go.

The <bignum>^0 notation is scoring, right?  I need to read up more on 
that to figure out what that's accomplishing in your recipe.

Why the "[(_at_)]" rather than just "@" (second two regexps) (or "[.]" in the 
first regexp)?  I don't see how a character class that matches only a 
single character differs from that character appearing literally?

And looking at yours has already told me something about why mine didn't 
match as far in as I had expected it to, so that's useful!

I'm actually going to have to put in explicit recipes to *keep* some 
mailing lists from going into special directories -- a number of 
announce lists I want to show up in my normal email, so I'll read them.  
I find this amusing.
I hope this helps.
  

Yes, and thank you very much.

-- 
David Dyer-Bennet, dd-b(_at_)dd-b(_dot_)net; http://dd-b.net/
Snapshots: http://dd-b.net/dd-b/SnapshotAlbum/data/
Photos: http://dd-b.net/photography/gallery/
Dragaera: http://dragaera.info

____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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