procmail
[Top] [All Lists]

Re: Using vars in condition test?

1995-12-19 17:58:42
On Tue, 19 Dec 1995, Alan Stebbens wrote:

Use "$" (as described in the procmailrc man page):

    :0
    * $ ^To:.*$LISTNAME
    procmail-folder

Nice!  Now, is there a way to keep $LISTNAME in a separate UNIX file so 
that it can be changed on the fly without ever having to change my 
.procmailrc file?  That would be handy.

I moderate a majordomo list in which I automatically pipe certain 
trustworthy list member's posts to the approve script.  I do this using 
the following construction: 

* From:.*(mail(_at_)address1|mail(_at_)address2|mail(_at_)address3)
| approve

It would be nice to keep the mail addresses in a separate file.

Examine this piece of "ackmail.rc", my recipe to auto-acknowledge mail,
depending upon whether or not an address ($SENDER) already exists within
a file:

    :0 Wh
    | fgrep -i -s "$SENDER $DATE" $ACKS

The "fgrep" succeeds if the address exists in the cache file ($ACKS).
When a pipe command succeeds and the "f" and "c" flags are not given,
the mail is considered to have been "delivered", and procmail stops
processing.

You could also use "multigram" to do address matching; it is part of
SmartList, in that it gets compiled by a SmartList installation, but it
is kept with the procmail sources.

Thus, to do something like you suggest above:

1. put a list of newline-separated addresses in the file ADDRLISTFILE.

2. use the file in the following recipe:

    # Build ADDRLIST as a regexp, with addresses separated with "|";
    # be sure to drop the trailing newline
    ADDRLIST=`cat $ADDRLISTFILE | tr '\012' '|' | sed -e 's/|$//'`
    :0
    * $ ^From:.*($ADDRLIST)
    | approve

HTH.

Alan