On Tue, 18 May 1999 12:24:31 +0200 (MET DST), Holger Wahlen
<H(_dot_)Wahlen(_at_)fz-juelich(_dot_)de> wrote:
Daniel Kabs wrote:
SUBJECT=`formail -xSubject:`
:0 w
* ^To:(_dot_)*root(_at_)physik(_dot_)uni-kl(_dot_)de
{
:0 fw
|formail -I "Subject: [root]$SUBJECT"
:0
/var/spool/mail/kabs
}
:0
* ^TO_root(_at_)physik(_dot_)uni-kl(_dot_)de
{
:0 fhw
| formail -I "Subject: [root]$SUBJECT"
:0:
/var/spool/mail/kabs
}
Two additional observations:
- You can save some resources by avoiding the first call to formail.
This is somewhat involved (to the newbie) but basically amounts to
setting SUBJECT using Procmail's built-in constructs rather than
by invoking a (relatively expensive) external process.
:0
* ^Subject:\<*\/.*
{ SUBJECT=$MATCH }
- Filter + save can be compressed into a single action -- this is
just a matter of what's "elegant" and not something that you
should worry a lot about.
:0:
* ^TO_root(_at_)physik(_dot_)uni-kl(_dot_)de
| formail -I "Subject: [root] $SUBJECT" >>/var/spool/mail/kabs
Furthermore, you probably should not hard-code /var/spool/mail/kabs if
it's identical to your $DEFAULT -- in the (somewhat unlikely, but by
no means theoretical) event that the mail spool is moved somewhere
else, you would need to hunt down and change all Procmail recipes
where the path is used, whereas if you always use $DEFAULT, fixing
everything is a matter of recompiling Procmail.
Finally, unless you need the SUBJECT variable for something else as
well, you should put off extracting it until you know you are dealing
with mail for root.
To summarize:
:0:
* ^TO_root(_at_)physik\(_dot_)uni-kl\(_dot_)de
* ^Subject:\<*\/.*
| formail -I "Subject: [root] $MATCH" >>$DEFAULT
There is one caveat: If you receive mail without any subject at all,
this recipe will not trigger (due to the second condition, which is
only there for the side effect of grabbing the original Subject). To
fix that, you'd have to break this back up into a compound recipe in
braces.
Hope this helps,
/* era */
--
.obBotBait: It shouldn't even matter whether <http://www.iki.fi/era/>
I am a resident of the state of Washington. <http://members.xoom.com/procmail/>
* Sign the European spam petition! <http://www.politik-digital.de/spam/en/> *