procmail
[Top] [All Lists]

Re: Match senders' names from a file

1996-05-17 07:44:41
Edna Cheng <edna(_at_)st(_dot_)com(_dot_)sg> writes:
I'm new to procmail and have it installed on Digital UNIX with 
sendmail, and is working at least for simple mail filtering and 
forwarding. I need to filter mails from a list of senders whose names 
are stored in a file. I copied the script from procmailex example :

URGMATCH=`cat $HOME/.urgent`

:0 B:
* $^From:.*${URGMATCH}
urgent

----------
I'm sure the address matches, but it doesn't work. The log writes 
...
No match on "^From(_dot_)*name(_at_)somewhere
..
Folder: **Bounced**"

Have I missed out anything?


The file $HOME/.urgent needs to contain a regular expression for all the
addresses, i.e., something like:

guenther(_at_)gac\(_dot_)edu|guenther(_at_)stolaf\(_dot_)edu|philipg(_at_)bronco\(_dot_)cna\(_dot_)tek\(_dot_)com

all on one line.  If you _do_ do that, then you need parens in the recipe:

:0 B:
* $ ^From:.*(${URGMATCH})
urgent


If you want the $HOME/.urgent file to just contain one address per
line, then you have to use something like sed, perl or awk instead of
cat:


URGMATCH=`perl -p -0377 -e 's:\n*$::;s:\n+:|:g;s:\.:\\.:g' $HOME/.urgent`
URGMATCH=`sed -e ':t' -e N -e 's:\n:|:g' -e '$!bt' -e 's:\.:\\.:g' 
$HOME/.urgent`
URGMATCH=`awk -F. '{ if (NR > 1) { buf = buf "|" $1 } else { buf = $1 } for (i 
= 2; i <= NF; i++) buf = buf "\\." $i;} END { print buf }' $HOME/.urgent`


Take your pick (I'd put _less_ whitespace in the awk version, but I don't
trust awk's lexer).

Philip Guenther

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