[vox-tech] How to apply procmail filters to existing mailbox?
Peter Jay Salzman
vox-tech@lists.lugod.org
Thu, 26 Sep 2002 14:03:31 -0700
hi graham,
begin Graham Freeman <graham@calteg.org>
>
> Howdy,
>
> About 2 weeks ago I broke my procmail filters in such a way that they
> started silently discarding most of my e-mail for about 6 hours
OMG! i've always found that procmail is _really_ good about having the
least destructive default action. that's AWFUL.
> until I
> discovered the problem and (for lack of time) disabled all my procmail
> filters. Fortunately I retained the mail server logs, so I can probably
> figure out at least whose e-mail I missed.
fwiw, whenever i make a change to my procmail filter, i always send test
msgs to make sure it works. there are fancy shmansy ways of doing this,
but telnetting to your SMTP port and sending email with various From:
and Subject: lines works for me. i don't test everything, but it at
least a few test emails ups my confidence that i haven't made a huge
error.
> Now that I've been able to find & fix the problem with my filters, I need
> some way to apply the filters to the ~3,000 unfiltered messages that wound
> up in my inbox since then. I'd really prefer not to have to go through
> these messages by hand. Unfortunately, all the procmail documentation I
> can find assumes that you're using it only as the e-mail comes in, not on
> an existing mailbox.
>
> Can anyone tell me how to apply my existing .procmailrc to my existing
> /var/mail/graham inbox file?
sure.
cp /var/mail/graham graham.backup
mv /var/mail/graham graham.old
formail -s procmail < graham.old
the -s option causes standard input to be split into separate emails,
and then feed them individually to the program specified immediately
after the -s option.
the reason why you have to move /var/mail/graham to graham.old is
because email taken from /var/mail/graham which doesn't match a recipe
is sent to your default mailbox, which happens to be right back into
/var/mail/graham.
a nice endless loop.
the reason for the first "cp" is "just because". it's a good idea. :)
hth,
pete