What appears below are my personal notes I wish were part of my long-term memory but don't always seem to fit. I strive for accuracy and clarity and appreciate feedback. If applying any of this information anywhere, confirm for youself the correctness of your work as what you see below might very well be, albeit unintentionally, incorrect or misleading. These notes are here as an easy reference for myself.
Information worthy of a more formal presentation will appear elsewhere than this "Scratch" area. - ksb
Table of Contents
Once procmail is set up, when a piece of mail arrives for you, sendmail looks in your ~/.forward file and pipes the incoming mail to procmail (step 5), procmail reads your ~/.procmailrc file (step 3) to find your recipes file (step 2). The recipes file (based on the very strange syntax that is unique to procmail) tells procmail what to do with each piece of mail.
In this example there is only one rule which says: "place all mail with 'email@example.com' in any of the To or CC fields into a mail folder called 'memail'". Mail that doesn't match any rules in your recipes file 'falls through' and goes to your inbox.
You, of course, don't need to filter email in this way. I prefer it over having filter rules in the client as they live in just one place (on the server) and won't differ from client to client. None of this will work of course unless you are using IMAP and have access to your account on mail server's filesystem.
$ mkdir ~/.pm/
This is the place where your recipes and log files will live.
Create a ~/.pm/recipes file with all your procmail recipes which are the instructions on what procmail should do with each incoming mail. This is the hard part as procmail has it's own language for defining recipes, here is a simple example:
:0: * ^TO_me@example.com memail
Procmail recipes can become far more complicated than this.
Make the following a ~/.procmailrc file:
#Replace `mail' with your mail directory (Pine uses mail, Elm uses Mail) MAILDIR=$HOME/mail DEFAULT=/var/mail/$LOGNAME #Directory for storing procmail log and rc files PMDIR=$HOME/.pm LOGFILE=$PMDIR/log INCLUDERC=$PMDIR/recipes
Create the mail folder 'memail' and get your mail reader know that it is a mail folder. You may want to get your mailers to check it new mail periodically. (In Mozilla I create a mail.check_all_imap_folders_for_new preference (in the about:config page) and set it to true) which will make Mozilla mail checkk all IMAP folder for new mail.
When using sendmail, you probably don't need to specify a path to procmail because sendmail will only use it's own 'safe' version of procmail anyway. I believe that it might be possible for sendmail to not even look at ~/.forward files and go simply with the existance of a ~/.procmailrc file for using procmail, so a ~/.forward may not even be necessary.
The mailstat command is used to read your procmail log file. The following command will list in a table the result of each rule in you recipes file and rotate your current ~/.pm/log file to ~/.pm/log.old:
$ mailstat -l ~/.pm/log