procmail
[Top] [All Lists]

Re: /dev/null recipe

1997-12-19 14:57:42
W. Wesley Groleau suggested,

| Or if you want to discard messages that have that anywhere in the header,
| but NOT in the subject line (so you can exchange messages ABOUT them but
| not FROM them):
| 
| :0
| * ? formail -ISubject: | grep -w -i Majordomo(_at_)tradinghouse(_dot_)com
| /dev/null

It can be done without formail, grep, and a shell to connect them:

  :0
  * 1^1 ^(_dot_)*majordomo(_at_)tradinghouse\(_dot_)com\>
  * -1^1 ^Subject:(_dot_)*majordomo(_at_)tradinghouse\(_dot_)com\>
  /dev/null

To explain the parts that look funny:

First, the regexp of the first condition is left-anchored so that each
header field containing the string will be counted only once.  That way
a message where the string appears only in the subject but the subject
contains it multiple times, like this:

Subject: Majordomo(_at_)tradinghouse(_dot_)com stinks!  
Majordomo(_at_)tradinghouse(_dot_)com
     sucks!  Majordomo(_at_)tradinghouse(_dot_)com bites!

won't get scored as 3-1=2 and mistakenly dropped into /dev/null.

Second, the second condition has x=1 instead of x=0 because there could be
more than one Subject: field, and we have to remove them all from conside-
ration.

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