procmail
[Top] [All Lists]

Re: Killing mails ?

1997-12-22 15:43:09
On Mon, 22 Dec 1997 15:23:37 -0500 Vikas Agnihotri wrote
I want to sink mails satisfying certain criteria and right now, I have the
following in my rc file.

[ rc snippet snipped ... ]

Questions:

1. Well, this is fine, but I want to add to the list and I can see the list
getting pretty long.
  How can I put all this in a file and use 
* ? egrep -f killfile

Basically, just put a list of regular expressions (one per line) in a file
named 'killfile' in $MAILDIR.  You could also try

:0 Wh
| egrep -f killfile

which will drop the message (i.e. consider it 'delivered') if one of its
headers matches a pattern in "killfile."

2. Is using 'egrep' less efficient than giving a long (RE1|RE2|...) to
procmail?

Probably somewhat less efficient -- it forks an extra program for each
incoming mail.  However, this solution is quite maintainable.  You may
want to do some timing tests before you throw out egrep.

3. Right now, I am only killing based on the envelope From_ header. What if
I want to kill 
 o based on certain other headers or 
 o even patterns in the message-body or 
 o worse even, patterns in one of the text/plain attachments of the
   message? (some mailer daemons return the original message or diagnostic
   message as a MIME text/plain attachment)

In the 'egrep' scenario, you would include other headers in the regular
expressions in 'killfile.'  To match patterns in the body, however, you
would need to use anothe egrep recipe without the 'h' flag i.e.

:0 W
| egrep -f bodykill

4. What if I want to combine the 2 approaches i.e.
  o From_ header contains RE1 and body contains RE2

I don't know the _best_ way to do this, but the following
should work:

:0..
* <test for From_ header contents>
{
 :0 B ...
 * <test for Body contents>
 <action>
}

-- 
Chris Mikkelson                 
mikk0022(_at_)maroon(_dot_)tc(_dot_)umn(_dot_)edu
U of M Tuba and Student    "Life is too short for windows..."
'94-present

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