Timothy Luoma <luomat(_at_)peak(_dot_)org> writes:
Ok, here's another followup question.
When I get a duplicate message, I want to know where the previous dups went.
IE today I got 3 dups of one message. The first got filtered, the others
ended up in my Dups mailbox, but had to go back through the logs.... Is there
a way to find this information easier, perhaps even have it put into an
X-Header?
X-Dup: earlier copy went to 'otherbox'
Sure. Change all of your current delivering recipes to instead of make
note in a variable of what they would have done, then check for dups,
and then (if it wasn't a dup) perform the delivery. If all your delivering
is done with one basic form of action (e.g., they're all mailfolders, or
they're all pipe actions using appnmail), then this is easy:
:0
* ^Return-Path: <?procmail-request@
{ MAILBOX = procmail }
# other such checks
# check for duplicates
:0 Whc: msgid.lock
|formail -D 8192 msgid.cache
:0 a
{
# It was a dup! Note it and send it to the Dups folder
:0 hf
| formail -I"X-Dups: earlier copy went to ${MAILBOX-the spool}"
MAILBOX = Dups
}
# Deliver the message using appnmail (for NeXT's Mail.App's mailboxes)
:0
| appnmail $MAILBOX
Even if you have several types of delivery actions you can still pull
this off, it just gets slightly more complicated.
:0
* ^Return-Path: <?procmail-request@
{ MAILBOX = procmail }
:0
* ^Subject: your cron job
{ ACTION = 'gzip >>cron.gz' }
# check for duplicates
:0 Whc: msgid.lock
|formail -D 8192 msgid.cache
:0 a
{
# It was a dup! Figure out how to describe where it went.
# Remember: ${VAR+some text} either expands to "some text"
# (if VAR was set) or to _nothing_ (if it wasn't), while
# ${VAR-some text} either expands to VAR's value (if it
# was set) or "some text" (if it wasn't).
DEST = "${MAILBOX+to the mailbox}$MAILBOX"
DEST = "$DEST${ACTION+via the command}${ACTION}"
DEST = ${DEST-to the mail spool}
# Make a note of it in the header
:0 hf
| formail -I"X-Dups: earlier copy delivered $DEST"
# Change where it this copy goes
ACTION
MAILBOX = Dups
}
# Should we deliver with appnmail?
:0
* ! ${MAILBOX+!}
| appnmail $MAILBOX
# ...or was it a program action? We use eval here so that the shell
# will reparse and notice redirections (>>'s) and other shell syntax.
:0
* ! ${ACTION+!}
| eval $ACTION
Get the idea?
Philip Guenther