welcome: please sign in

Revision 3 as of 2007-04-15 13:16:59

Clear message
Edit

MemberManual / Email / Procmail

This page has a sample .procmailrc file with comments. You should use either a .procmailrc file or a .forward file, but not both.

1. Which should I use?

If you simply want to send mail to another email address, using a .forward file is your best bet.

If you want to exercise control over your email by splitting it into various mailboxes or (in our case) IMAP folders based on custom criteria using the power of regexps, perhaps a .procmail file would be best for you.

2. What does this file do?

3. What does this file not do?

Take a look at /home/mwolson/.procmailrc and the /home/mwolson/procmail.d directory for a procmail configuration that is composed of several smaller files.

4. Example file

# Example procmailrc filters
#
# We use a maildir here at hcoop.net
MAILDIR=$HOME/Maildir
DEFAULT=$MAILDIR/

# See the manpages `procmailrc' and `procmailex' for explanations
# of the syntax involved.

# The following 2 rules come before the spam rules because we
# want to make sure that email from these people get through.
# It's a form of whitelisting.

# Stuff from the family
:0:
* ^From.*(olsonh@bethelcollege|rogero@saintjoe|risnerolson1@msn)
.Family/

# Work-related
:0:
* ^From.*(rodgerh|yodera)@bethelcollege
.Work/

# If mail hasn't been put through spamassassin, do so now
:0 fW
* !^X-Spam-Level:
| spamc

# All mail tagged as spam (eg. with a score higher than the set
# threshold) is definitely spam.
:0:
* ^X-Spam-Status: Yes
.Spam.Definitely/

# If it scores 3 or better, it's probably spam.
:0:
* ^X-Spam-Level: \*\*\*
.Spam.Probably/

# The Debian Bug-Tracking System forwards me a copy of each bug report
# I send in.  Since I don't already have a copy of this report, put it
# in my Sent box.
:0:
* ^From:.*mwolson@member\.fsf\.org
* ^To:.*submit@bugs\.debian\.org
.Sent/

# Local mail (error messages and the like)
:0:
* ^(To:|From).*tuxtanker\.mwolson\.org
.Local/

# Vending stuff
:0:
* ^To:.*me(\+|_)vending@mwolson\.org
.Vending/

# GNU related email
:0:
* ^To:.*(me\+gnu@mwolson\.org|mwolson@gnu\.org)
.Gnu/

# School-related
:0:
* ^To:.*me\+purdue@mwolson\.org
.School/

# Crap sent to all Bethel students
:0:
* ^(To|Cc):.*[Rr]-[Uu]sers_
.Spam.Ignore/

# Bug reports
:0:
* ^(From|To|C[c]):.*(bugs\.debian\.org|bugzilla\.)
.Bugs/

# LifeReader mailing list
:0:
* ^(From|To|C[c]):.*liferea-devel@lists
.Lists.LifeRea/

# Neki_Fujiyama (Samurai Pizza Cats) list
:0:
* ^(From|To|C[c]):.*[Nn]eko_[Ff]ujiyama@yahoogroups
.Lists.Neko_Fujiyama/

# Hcoop mailing list
:0:
* ^To:.*users@hcoop
.Lists.HCoop/

# InfoWorld newsletters
:0:
* ^From.*@newsletter\.infoworld
.Lists/

# Other lists
:0:
* ^(From|To|C[c]):.*(@lists\.|@yahoogroups)
.Lists/

# Anything I've sent should go to Test
:0:
* ^From:.*(mwolson@|@mwolson\.org)
.Test/

5. Another Example

I based my .procmailrc on the file above. However, I don't trust my procmail coding skills, so I had procmail create a log file of the messages that it receives, as well as a backup copy of each message for testing purposes. I also decided that the "Sender:" field is the best one to use for the lists that I receive, so I filter on this field. I took code in my .procmailrc from the "procmailex" man page, which I highly recommend.

I created the directory "log" in my home directory for the log file before putting the .procmailrc in place. I also created the folders to which mail would be filtered in thunderbird, although I'm not absolutely sure if this step is necessary.

Note that you should probably comment out the "backup" section once you're sure that your code works in order to save space. You will also have to rotate or truncate the procmail log file manually, or write a script for cron to use.

{{{## JustinLeitgeb .procmailrc

# We use a maildir here at hcoop.net MAILDIR=$HOME/Maildir DEFAULT=$MAILDIR/

# Create a log file in my home directory under "log", which will have to be # created manually. LOGFILE=/home/leitgebj/log/procmail.log

# Make a backup of all mail that we'll wipe out when we're sure that # filtering is working correctly. :0 c .backup/

# CFP (call for papers) list :0: * ^Sender.*owner-cfp@lists.sas.upenn.edu .lists.CFP/

# plone-users :0: * ^Sender.*plone-users-bounces@lists.sourceforge.net .lists.plone-users/

# nflug :0: * ^Sender.*nflug-bounces@nflug.org .lists.nflug/}}}