3648
Comment: Migrate from old wiki.
|
5638
Get rid of spamc rule
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
#pragma section-numbers off | |
Line 2: | Line 3: |
This page has a sample {{{.procmailrc}}} file with comments. You should use either a {{{.procmailrc}}} file or a {{{.forward}}} file, but not both. |
This page describes how to use Procmail to filter mail. It includes HCoop-specific instructions and a sample {{{.procmail.d/procmailrc}}} file with comments. |
Line 6: | Line 5: |
= Which should I use? = | [[TableOfContents]] |
Line 8: | Line 7: |
If you simply want to send mail to another email address, using a {{{.forward}}} file is your best bet. |
= Introduction = |
Line 11: | Line 9: |
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. |
Procmail instructions are kept in the {{{~/.procmail.d/procmailrc}}} file. You should have a directory under your home AFS directory called {{{.procmail.d}}}. To activate procmail, simply create a file in that directory called {{{procmailrc}}}. |
Line 16: | Line 11: |
= What does this file do? = | Since we like to document by means of an example, the remainder of these instructions focus on two specific example {{{~/.procmail.d/procmailrc}}} files. = Points to keep in mind = * It is highly recommend to put your procmail log in {{{~/.logs/mail/procmail.log}}} rather than elsewhere. * Use appropriate values for the HOME, MAILDIR, and DEFAULT options, based on those used in the examples. = What do these examples do? = |
Line 21: | Line 23: |
= What does this file not do? = | = What do these examples not do? = |
Line 26: | Line 28: |
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. = Example file = |
= Example 1: MichaelOlson's setup = |
Line 38: | Line 36: |
# If you want to keep track of where mail has been delivered, # uncomment this. If enabled, be sure to trim this file once # in a while (using cron is one way), because otherwise it can # grow quite large. It is strongly recommended to use the # path given here, so that the logs gets placed in a writable # location. #LOGFILE=$HOME/.logs/mail/procmail.log |
|
Line 47: | Line 53: |
:0: * ^From.*(olsonh@bethelcollege|rogero@saintjoe|risnerolson1@msn) |
:0 * ^From.*(familymember1@msn|familymember2@yahoo) |
Line 52: | Line 58: |
:0: * ^From.*(rodgerh|yodera)@bethelcollege |
:0 * ^From.*person@somecollege |
Line 55: | Line 61: |
# If mail hasn't been put through spamassassin, do so now :0 fW * !^X-Spam-Level: | spamc |
|
Line 63: | Line 64: |
:0: | :0 |
Line 68: | Line 69: |
:0: | :0 |
Line 75: | Line 76: |
:0: * ^From:.*mwolson@member\.fsf\.org |
:0 * ^From:.*me@hcoop\.net |
Line 81: | Line 82: |
:0: * ^(To:|From).*tuxtanker\.mwolson\.org |
:0 * ^(To:|From).*local\.domain\.org |
Line 86: | Line 87: |
:0: * ^To:.*me(\+|_)vending@mwolson\.org |
:0 * ^To:.*me(\+|_)vending@domain\.org |
Line 90: | Line 91: |
# GNU related email :0: * ^To:.*(me\+gnu@mwolson\.org|mwolson@gnu\.org) .Gnu/ |
|
Line 96: | Line 92: |
:0: * ^To:.*me\+purdue@mwolson\.org |
:0 * ^To:.*me\+school@domain\.org |
Line 100: | Line 96: |
# Crap sent to all Bethel students :0: |
# Crap sent to all students :0 |
Line 106: | Line 102: |
:0: | :0 |
Line 111: | Line 107: |
:0: | :0 |
Line 116: | Line 112: |
:0: | :0 |
Line 121: | Line 117: |
:0: | :0 |
Line 126: | Line 122: |
:0: | :0 |
Line 131: | Line 127: |
:0: | :0 |
Line 136: | Line 132: |
:0: | :0 |
Line 140: | Line 136: |
= Example 2: JustinLeitgeb's setup = 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 ## Modified Sun Apr 15 01:41:34 EDT 2007 # We use a maildir here at hcoop.net MAILDIR=$HOME/Maildir DEFAULT=$MAILDIR/ # Create a log file LOGFILE=$HOME/.logs/mail/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/ ## Filter all of the mailing lists that we get into different ## folders. # 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/}}} |
This page describes how to use Procmail to filter mail. It includes HCoop-specific instructions and a sample .procmail.d/procmailrc file with comments.
Introduction
Procmail instructions are kept in the ~/.procmail.d/procmailrc file. You should have a directory under your home AFS directory called .procmail.d. To activate procmail, simply create a file in that directory called procmailrc.
Since we like to document by means of an example, the remainder of these instructions focus on two specific example ~/.procmail.d/procmailrc files.
Points to keep in mind
It is highly recommend to put your procmail log in ~/.logs/mail/procmail.log rather than elsewhere.
- Use appropriate values for the HOME, MAILDIR, and DEFAULT options, based on those used in the examples.
What do these examples do?
- Separates mail into different folders based on who it is from or who it is addressed to.
- If an email message did not get checked by the central spamassassin daemon, make sure it gets checked. It calls the client program instead of starting another spamassassin process. Most messages have already been checked -- these we don't touch. Occasionally spamassassin misses checking a message or two, somehow.
What do these examples not do?
Force spam checking with a custom set of rules. The admins do not recommend checking spam with custom rules, since it causes spamassassin to be invoked twice for each message.
- This file can be split into smaller task-based files, but this is not done in the example.
Example 1: MichaelOlson's setup
# Example procmailrc filters # # We use a maildir here at hcoop.net MAILDIR=$HOME/Maildir DEFAULT=$MAILDIR/ # If you want to keep track of where mail has been delivered, # uncomment this. If enabled, be sure to trim this file once # in a while (using cron is one way), because otherwise it can # grow quite large. It is strongly recommended to use the # path given here, so that the logs gets placed in a writable # location. #LOGFILE=$HOME/.logs/mail/procmail.log # 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.*(familymember1@msn|familymember2@yahoo) .Family/ # Work-related :0 * ^From.*person@somecollege .Work/ # 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:.*me@hcoop\.net * ^To:.*submit@bugs\.debian\.org .Sent/ # Local mail (error messages and the like) :0 * ^(To:|From).*local\.domain\.org .Local/ # Vending stuff :0 * ^To:.*me(\+|_)vending@domain\.org .Vending/ # School-related :0 * ^To:.*me\+school@domain\.org .School/ # Crap sent to all 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/
Example 2: JustinLeitgeb's setup
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 LOGFILE=$HOME/.logs/mail/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/}}}