procmail
[Top] [All Lists]

Re: Wildcard usage in procmail

1998-05-20 23:16:31
On Wed, 20 May 1998, Matt Cortes wrote:
exact same machine.  The problem though is how do I make a filter that
will account for host names sometimes showing and sometimes not showing.

First, you've used the ^TO token wrong. It's a token for a big regexp that
includes the colon and leading text, so you don't need ":.*". I like to
add () to it for a visual seperator. They do nothing to the regexp in this
case. 
        * ^TO()link@([-_a-z0-9]+\.)*pulsar\.net\>

The regexp I've added to allow zero or more unknown hostnames is

        ([-_a-z0-9]+\.)*

I've also added a \ to escpe the regexp meaning of ".", and added the 
procmail token " \> " to match the end of a word, so that the expression 
won't match "pulsar.netcom.com".

One other thing too is I know there is a ^TO macro which covers the To:,
Cc:, and Bcc: fields..  but is there a macro for the entire header?  Like
what if I want to filter mail that has a maillist address ANYWHERE in the
header?  I have some maillists which sometimes has its address in the
From: field, and sometimes its in the To: field (And yet it gets to me
somehow.  heh).  Or is that where I need to start using muliple
conditions?  If so an example would be great.

By default, procmail feeds the entire head to the condition line. The
exception is when the recipe has the B or HB flags on the start of the
recipe. This condition line will match "foo(_at_)bar" anywhere in the head: 

        * foo(_at_)bar

or better still: ( in this example the () actuallly does something! )

        * ()\<foo(_at_)bar\>

Most of this is covered pretty well in the procmailrc manpage and the 
egrep manpage, with examples in the procmailex manpage.

David H.

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