GET YOUR HANDS DIRTY

setup

wget -O - http://doc.nethence.com/download/dot.procmailrc > dot.procmailrc
cp dot.procmailrc .procmailrc
vi ~/.procmailrc

this sample is optimized against a NetBSD system. Change at least PATH (remove /usr/pkg/bin) if you want to use it against GNU/Linux. You might want to change DOMAIN.TLD, ACCOUNT and UNIXACCOUNT too.

diff -bu dot.procmailrc .procmailrc

testing

vi .procmailrc.dryrun
procmail VERBOSE=yes DEFAULT=/dev/null .procmailrc.dryrun < Maildir/.test/cur/SOMEMSG

ready to go

vi ~/.forward

"|IFS=' '&&p=/usr/pkg/bin/procmail&&test -f $p&&exec $p -f-||exit 75"

or into main.cf,

mailbox_command = /usr/bin/procmail

or the same with -f- (not needed) or the same with -d ${USER} (does not work).

references

heavy-duty mailbox RE-PROCESSING

print cleaning-up $HOME/Maildir/msgid.cache just in case there is one... \\c
rm -f $HOME/Maildir/msgid.cache && print done

MBOX,

mv mbox mbox.tmp
#watch procmail logs
formail -s procmail < mailbox.tmp

Maildir,

mv maildir/ maildir.tmp/
find $1/cur $1/new -type f | while read msg; do
        print $msg... \\c
        procmail < $msg && rm -f $msg && print done
done

heavy-duty troubleshooting – SAVE THE WORLD

splitting files,

grep '^Return-Path: ' brokenmbox | wc -l 

that number minus 2 (think about it),

csplit -n 4 -s brokenmbox /^Return-Path:/ {901} 

find files about 10MB,

find . -type f -size +$((1024 * 1024 * 10))c             

move all matching files to another folder,

find .lists.* -type f -print0 | xargs -0 -I file mv file tosort/
rm -rf .lists.*