procmail
[Top] [All Lists]

Re: Q: Putting action line in variable

1997-08-09 14:01:00
Gregory Sutter asked,

| I want to put the entire action line for a set of recipes in a variable, as:

| # This sets the default action for all recipes in this base junkfilter file.
| ACTION="|formail -i 'X-Fkey: junk' -i 'X-Spammer: `echo $SPAMMER`' >> jmtest"

That's been discussed recently.  One suggestion is to use (please correct
this if needed, Philip)

  | eval "$ACTION" ;

as the action line; however, you'll need to name the local lockfile with
":jmtest.lock" on the flag line, because procmail will be unable to infer
a local lockfile name from the form above.

Alternatively, if disk space and inodes are in adequate supply, you can have
an action of

  { INCLUDERC=/path/to/one_for_this_action }

[a relative path from $MAILDIR works as well], and (let's also fix the
quoting)

 :0:
 |formail -i 'X-Fkey: junk' -i "X-Spammer: $SPAMMER" >> jmtest

in the included rcfile.  (With that method there will be no need to assign
or use the variable $ACTION.)

| # then various recipes...
|
| # junk mail software.
| SPAMMER="junkmail software"
| :0 :
| * ^Received:.*(Cyber-Bomber|bulk_mailer|from stealth)
| $ACTION
|
| # IEMMC does NOT keep and use a "remove list".
| SPAMMER="IEMMC"
| :0 :
| * X-Advertisement:.*iemmc
| $ACTION

I think what you really need is a different approach:

  SPAMMER # make sure it goes in unset

  :0
  * ^Received:.*(Cyber-Bomber|bulk_mailer|from stealth)
  { SPAMMER="junkmail software" }

  :0
  * ^X-Advertisement:.*iemmc
  { SPAMMER=IEMMC }

  ... etc. ...

  :0: # if $SPAMMER has been given a non-null value
  * SPAMMER ?? .
  | formail -i 'X-Fkey: junk' -i "X-Spammer: $SPAMMER" >> jmtest

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