Quick Procmail Setup

Intro

Procmail is an all-purpose mail filtering program. I maintain this page to stop my friends from complaining to me about all the spam they get. Check out Sven Guckes's Procmail page for more information.

Setup files and directories

First, create a few files and directories so you can see what procmail is going to work with.

mkdir ~/.pmdir
touch ~/.pmdir/log
touch ~/.pmdir/recipes
touch ~/.procmailrc

mkdir ~/mail/.inboxes
touch ~/mail/.inboxes/INBOX
touch ~/mail/.inboxes/work
touch ~/mail/.inboxes/friends
touch ~/mail/.inboxes/personal

Contents of relevant files

Now use your favorite text editor and a little copy paste action to put something in those files.

~/.pmdir/recipes
# I like to keep recipes in a separate file
# Be careful with the regular expressions, read the man page for specifics
:0:
* ^FROM:.*narusso*
friends

:0:
* ^TOlabs
work

:0
* ^FROM:.*(aol.com|spamsenders)
/dev/null

:0:
INBOX

This is the file that makes everything start happening, so don't create it until everything else is in place.

~/.procmailrc
# Set on when debugging
VERBOSE=on

# Directory where procmail defaults to put new mail files
MAILDIR=$HOME/mail/.inboxes
DEFAULT=$HOME/mail/.inboxes/

# Directory for storing procmail log and rc files
PMDIR=$HOME/.pmdir

LOGFILE=$PMDIR/log

# by default, the recipes are in the current file
# this tells procmail to get them elsewhere
INCLUDERC=$PMDIR/recipes

If your system uses procmail as it's MDA, you won't need this .forward file, because procmail will run just based on the existence of your .procmailrc file. Try leaving it out of the setup for now.

~/.forward
"|IFS=' ' && exec /usr/local/bin/procmail -f- || exit 75 #YOUR_USERNAME" 

Setting up Pine to see the new inboxes

In Pine, go to Main Menu, Setup, Config. Change the following value:

inbox-path               = <No Value Set: using "/var/mail/username">
to this:
inbox-path               = ~/mail/.inboxes/INBOX

This way pine will know where to look for your regular incoming mail.

Next you want to page down (or do a whereis query) til you find these options:

            [X]  enable-incoming-folders
            [X]  expanded-view-of-folders
Make sure these are checked.

The last step is to add the incoming folders to pine's list. You'll have to restart pine first, since enabling incoming folders doesn't take effect until the next pine session. In the Folder List, choose Add to tell pine where to find the new inboxes you've created.

When you see the following questions, reply as indicated:

Name of server to contain added folder : <Return>
Name of folder to add : ~/mail/.inboxes/work
Nickname for folder "~/mail/.inboxes/work" :work

What Next?

Check the log file to see where messages are getting dumped. If you suspect procmail is messing something up, turn it off by renaming .procmailrc (and .forward if you are using it), so that procmail won't find them.

mv .forward .forward-testing
mv .procmailrc .procmailrc-testing

If the log file indicates that procmail is doing what you want it to, then turn off verbosity by editing the .procmailrc file, but make sure to watch the log file closely until you trust the setup. Be sure to remove the log file now and then if it starts to get too big.


Valid HTML 4.0!Valid CSS!