Kevin Benko <kevin(_at_)efn(_dot_)org> writes:
I was wondering if I could put the addresses (currently about 30) in
an external file and have the condition line grep the external file of
addresses for a match.
Below is a file I use for this, the condition does what you want.
In my .procmailrc I define a few variables to change some of the
defaults, and then include the file. Heed the egrep warning.
Mike
In .procmailrc:
BLACKLIST_GREP=/opt/gnu/bin/egrep
BLACKLIST_LOG=Blacklist.log
BLACKLIST_FILE=blacklist
BLACKLIST_EXITCODE=77
INCLUDERC=include/blacklist.rc
--------- start file include/blacklist.rc ---------
### blacklist.rc - delete junk mail.
###
### BLACKLIST_FILE is a list of regular expressions, one per line.
### Each is compared with the FROM address of the message and, if
### they match, the message is destroyed. A log of destroyed
### messages is kept in BLACKLIST_LOG. By default the message is
### bounced back to the sender with a "no permission" message;
### to suppress this set BLACKLIST_EXITCODE to 0 before including
### this file.
###
### 1997/09/18 Mike Rose Rename to blacklist, new variable BLACKLIST_SPOOL
### 1997/04/21 Mike Rose New variable for path to grep.
### 1997/04/10 Mike Rose Override FROM_ADDR
### 1996/07/24 Mike Rose Clean up exitcode, from_addr
### 1996/07/16 Mike Rose Ignore case of address
### 1996/07/13 Mike Rose
BLACKLIST_FILE=${BLACKLIST_FILE:-blacklist.data}
BLACKLIST_LOG=${BLACKLIST_LOG:-blacklist.log}
BLACKLIST_SPOOL=${BLACKLIST_SPOOL:-/dev/null}
FROM_ADDR=`formail -rtzxTo:`
FROM_ADDR=${FROM_ADDR:-nobody}
### GNU egrep doesn't run out of memory after just a few
### meta-characters during "egrep -f". SunOS egrep does.
### Recommend using fgrep instead of egrep if blacklist file
### doesn't contain regular expressions.
BLACKLIST_GREP=${BLACKLIST_GREP:-${EGREP:-egrep}}
:0h
* $ ? test -s $BLACKLIST_FILE
* ? echo "$FROM_ADDR" | $BLACKLIST_GREP -i -f $BLACKLIST_FILE
{
:0c
$BLACKLIST_SPOOL
EXITCODE=${BLACKLIST_EXITCODE:-77}
:0h: $BLACKLIST_LOG$LOCKEXT
| echo "`date` : $EXITCODE : $FROM_ADDR : `formail -zxSubject:`" >>
$BLACKLIST_LOG
}
--------- end file ---------