procmail
[Top] [All Lists]

Re: reprocessing mail

2001-12-04 16:13:06
From: bradw <tildar(_at_)sta-care(_dot_)com>

I had a script that would rum all mbox back threw my procmail filter
when i changed the .procmailrc file, but lost it some time ago. anyone
have a script that the can send me? or url that has one?

Sure, Brad.  In fact, it's right in the procmail man page:


man procmail> [reformatted line-length]
man procmail>  Procmail can also be invoked to postprocess an already
man procmail>  filled system mail- box.  This can be useful if you don't
man procmail>  want to or can't use a $HOME/.forward file (in which case
man procmail>  the following script could periodically be called from
man procmail>  within cron(1), or whenever you start reading mail):
man procmail>
man procmail>
man procmail>
man procmail>       #!/bin/sh
man procmail>
man procmail>       ORGMAIL=/var/spool/mail/$LOGNAME
man procmail>
man procmail>       if cd $HOME &&
man procmail>        test -s $ORGMAIL &&
man procmail>        lockfile -r0 -l1024 .newmail.lock 2>/dev/null
man procmail>       then
man procmail>         trap "rm -f .newmail.lock" 1 2 3 13 15
man procmail>         umask 077
man procmail>         lockfile -l1024 -ml
man procmail>         cat $ORGMAIL >>.newmail &&
man procmail>          cat /dev/null >$ORGMAIL
man procmail>         lockfile -mu
man procmail>         formail -s procmail <.newmail &&
man procmail>          rm -f .newmail
man procmail>         rm -f .newmail.lock
man procmail>       fi
man procmail>       exit 0

If the mail folder doesn't need to be locked against being written to
(i.e., if it's currently some other filename than your standard mail folder
and if no live processes are going to be writing to the file), you can
just do this with a one-liner:

        formail -s procmail < mailfile

Again: "mailfile" should NOT be the active spool if you go this route.

Besides being in the main man page, this is a FAQ and typically gets
asked a few times a month.  The searchable list archives and the FAQ link
from www.procmail.org are your friends.

-- 
dman
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

<Prev in Thread] Current Thread [Next in Thread>