procmail
[Top] [All Lists]

Re: variable for a long string

1997-07-24 14:03:00
Timothy Luoma asked,

| I have a lot of (spam-guard) recipes like this:
|
| :0
| * ^(From.|Reply-To:|Message-ID:|Received:).*badhost.com
|
| I've seen (I think) a way to put the various Headers into a variable, so I
| could do something like this:
|
| SpamHeaders="From|Reply-To:|Message-ID:|Received:"
|
| :0
| * ^$SPAMHEADERS.*badhost.com

The two gotchas are (1) you need the "$" modifier at the beginning of the
condition to get variables expanded and backquoted commands substituted;
(2) your suggested setup loses the parentheses, which you need; and (3)
variable names are case-sensitive, so $SPAMHEADERS will come up undefined
and empty if you've defined SpamHeaders but not SPAMHEADERS.

So I recommend these changes:

 SpamHeaders="^(From[ :]|Reply-To:|Message-ID:|Received:)(.*\>)?"

 :0 flags
 * $ ${SpamHeaders}badhost\.com
 * more conditions if any
 action

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