procmail
[Top] [All Lists]

Re: Problem with recipe; help needed!

1997-08-20 14:10:00
Though the Date: header on Gregory Sutter's post was August 20, this is
identical to a post I saw and answered last week ... and if someone had
asked me yesterday, before I saw this post, who asked this question last
week, I'd have said it was Gregory Sutter.

So maybe he didn't get my reply?  Let's try again:

| DOMAINS=`cat $PMDIR/domains/* | perl -p0e 's/\012(.)/\|$1/g; s/\./\\./g'`
| :0
| * 
^(((Resent-)?From|(X-)?Sender|Reply-To|Return-Path):?.*@(.*\.)*|Received:.*\<)$($DOMAINS)
| { SPAMMER="unauthorized domain" }

In order to get $DOMAINS expanded to the value of the variable (and not read
as newline-D-O-M-A-I-N-S) procmail needs the "$" modifier at the beginning of
the condition.

| I have also tried it without the $ that is before ($DOMAINS) in the line
| above.

Leave that extra "$" out; even with the "$" modifier at the beginning, a
dollar sign immediately before a parenthesis (or immediately before any
other character that is illegal in an variable name) will still be taken to
represent a newline.  Since what you're looking for will not have a newline
there, insisting on one will spoil the condition.

Also, :?.* is redundant; the .* will match whatever is there whether there
is a colon or not.

Let's try this and break it up for legibility:

* $ ^(((Resent-)?From|(X-)?Sender|Reply-To|Return-Path).*@|Received:)\
     (.*\>)?($DOMAINS)

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