procmail
[Top] [All Lists]

Re: Matching on file list of addresses?

1997-08-24 03:26:05
On Sun, 24 Aug 1997 00:44:09 -0400 (EDT),
Mike Frisch <mfrisch(_at_)saturn(_dot_)tlug(_dot_)org> wrote:
Can somebody tell me which approach I would take to have a procmail rule
read from a list of email addresses contained in a file?  What I would
like to do is send a message received confirmation to people I know
(listed in a text file).

Something like this, you mean?

    :0
    * ? formail -rtzxTo: | fgrep -sxf $HOME/people-who-want-autoreplies
    | formail -rt -I"Subject: Got yer message" \
      | $SENDMAIL $SENDMAILFLAGS -t

This is a bit too simplistic but the ? and the fgrep should move your
train of thought in the right direction. (Efficiency tip: grab
whatever is on the From: line into MATCH and fgrep for that instead.
Drawback: If you have friends who change the contents of their From:
line often, it's a hassle to try to keep up.)

Hope this helps,

/* era */

Here's a convoluted but somewhat more real-world version:

    :0  # will break if your buddies have many @:s in their From: lines
    * ^From:(.*\<)?\/[^<>@      ,()]+(_at_)[^<>@        ,()]+
    * ? fgrep -xs "$MATCH" $HOME/people-who-want-autoreplies
    * ^Subject:([       ]*re:)*[        ]*\/[^  ].*
    | formail -rt -I"Subject: Got your message re: $MATCH" \
      | $SENDMAIL $SENDMAILFLAGS -t

The first condition line (hopefully) grabs the From: address into MATCH.
The second condition checks if MATCH is found in the addresses file.
(You could list full e-mail addresses with full name and other
comments, but that's more likely to be volatile than the bare address.)
The third condition will grab the original Subject: line into MATCH so
they'll know what we're responding to. The action line will send off
an annoying confirmation message they will beg you to stop sending, if
I'm allowed an uninformed guess. 
  This is untested. Try to debug it at your own peril.
  The whitespace in the [] brackets and between "@" and "," consists of
one tab and one space.

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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