Axel Thimm <thimm(_at_)physik(_dot_)fu-berlin(_dot_)de> writes:
I am trying to set up some complicated (for me) procmail rules. I'd like to
have a copy of a mail sent to a couple of persons in every persons folder. If
this fails, then it should be put in a folder default (The mail is from an
"unknown" person). If at least one copy has been saved, then I don't want it
in default.
The problem is how to make procmail remember it did deliver something? The use
of c makes procmail forget about it.
Well, though it continues, it does remember: whenever procmail invokes
a delivering recipe (regardless of whether there's a 'c' flag on it),
procmail sets the LASTFOLDER variable to the location/program to which
it delivered. By testing that variable you can check to see whether
a delivery has taken place.
BTW: the 'c' flag goes _before_ the second colon, not after it. Anything
after a second colon on the :0 line is treated as the name of a lockfile.
Anyway, the following should illustrate:
# Clear the indication of whether delivery has taken place
# (this is in case there are recipes with the 'c' flag above
# this.
LASTFOLDER
:0 c:
* ^TObob\>
bob
:0 c:
* ^From.*\<bob\>
from-bob
:0 c:
* ^TObill\>
bill
# If one of the previous 3 recipes was invoked, LASTFOLDER will
# now be set. To check that we use David Tamkin's ${LF+!}
# trick: if LASTFOLDER is set, ${LASTFOLDER+!} expands to a '!',
# while if it's not set, it expands to nothing. The condition
# below will 'match' (be true) iff LASTFOLDER was set. We'll
# then drop the message as already handled, and let the rest of
# the .procmailrc handle those messages which haven't already
# been delivered, possibly via the implicit delivery to
# $DEFAULT. Yes, this is the reverse of what you originally
# proposed, but it's usually more flexible this way. Remember
# that the null regexp always matches.
:0:
* $ ! ${LASTFOLDER+!}
{
# drop the message as already delivered
HOST
}
Philip Guenther