Philip Guenther wrote,
Stan Ryckman <stanr(_at_)sunspot(_dot_)tiac(_dot_)net> writes:
I find the following conceptually simpler. (I usually use the "tee"
when debugging things, and then it's easy to yank it out of the pipe.)
MAILDIR=$HOME/Mail
:0:
* !^Subject:.*Re:
* ^Subject:.*get-pgp-key
| (formail -r ; cat $HOME/.pgpheader $HOME/.pgpkey) | \
tee -a Shadcat | $SENDMAIL -oi -t
Not to tear your idea to pieces, but...
Don't worry about it. I post to share what knowledge I might have,
as well as to learn from others. If nobody's ever going to shred
my ideas, I'll never learn anything.
As usual, you are right:
This saves a copy of the *outgoing* message to "Shadcat". Also, I don't
think formail propogates the 'From ' header, so Shadcat won't be in proper
mailbox formail. It doesn't work if Shadcat is a directory style mailbox,
and finally, you need to specify and explicit lockfile, as there's no ">>"
in the above command.
I have an explicit lock used by all the moves made by players of the
game I run, so I missed that issue. (I tested with LOGABSTRACT set,
and got a warning about not being able to determine the log file name,
so you're right there.) And, yup, what you get is useful for debugging
but it's not a mailbox.
That said, (:-)) some of the above can be fixed via tweaks. Add a lockfile
and move the tee earlier in the pipe:
:0:Shadcat.lock
* ! ^Subject:.*Re:
* ^Subject:.*get-pgp-key
* ! ^X-Loop: my-mailbox(_at_)my(_dot_)site
| tee -a Shadcat | (formail -rA"X-Loop: my-mailbox(_at_)my(_dot_)site"; \
cat $HOME/.pgpheader $HOME/.pgpkey) | $SENDMAIL -oi -t
That fixes all the but the directory style mailbox problem.
Actually, that fixes the mailbox problem too. The tee at the front
*does* give a legitimate mailbox format. (Tested that too.
Also requires a lock as you have provided)
Interestly, the procmail solution (reversed from David's original answer):
:0
* ! ^Subject:.*Re:
* ^Subject:.*get-pgp-key
* ! ^X-Loop: my-mailbox(_at_)my(_dot_)site
| (formail -rA"X-Loop: my-mailbox(_at_)my(_dot_)site"; \
cat $HOME/.pgpheader $HOME/.pgpkey) | $SENDMAIL -oi -t
:0 A:
Shadcat
actually uses one fewer process than the solution using 'tee'.
I could live with this one. As with tee, it makes it easy to
add/delete the filing to Shadcat. One extra process is of
little concern here, since nobody is waiting on it :-)
But since it's as easy to maintain, might as well use that.
Cheers
Stan (stanr(_at_)tiac(_dot_)net).