test
[hcoop/zz_old/ikiwiki] / ProcmailExample.mdwn
CommitLineData
ee25310d 1This page has a sample {{{.procmail.d/procmailrc}}} file with comments. You\r
2can use either a {{{.procmail.d/procmailrc}}} file or a {{{.forward}}} file,\r
3but not both.\r
4\r
5= Which should I use? =\r
6\r
7If you simply want to send mail to another email address, using a\r
8{{{.forward}}} file is your best bet.\r
9\r
10If you want to exercise control over your email by splitting it into\r
11various mailboxes or (in our case) IMAP folders based on custom\r
12criteria using the power of regexps, perhaps a {{{.procmail.d/procmailrc}}} file\r
13would be best for you.\r
14\r
15= What does this file do? =\r
16\r
17 * Separates mail into different folders based on who it is from or who it is addressed to.\r
18 * 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.\r
19\r
20= What does this file not do? =\r
21\r
22 * 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.\r
23 * This file can be split into smaller task-based files, but this is not done in the example.\r
24\r
25= Notes for Beta Testers on Peer 1 Infrastructure =\r
26\r
27If you are beta testing an account on the new Peer 1 infrastructure (you should know who you are), the default procmail file location has changed. You should have a directory under your home AFS directory called .procmail.d. In this directory, procmail will look for a file called procmailrc. Create this and you should be all set. Note the new AFS file locations in the example files below, and look at mwolson's and leitgebj's procmail configuration in their home directories for more examples.\r
28\r
29\r
30= Example file =\r
31\r
32{{{\r
33# Example procmailrc filters\r
34#\r
35# We use a maildir here at hcoop.net\r
36MAILDIR=$HOME/Maildir\r
37DEFAULT=$MAILDIR/\r
38\r
39# If you want to keep track of where mail has been delivered,\r
40# uncomment this. If enabled, be sure to trim this file once\r
41# in a while (using cron is one way), because otherwise it can\r
42# grow quite large. It is strongly recommended to use the\r
43# path given here, so that the logs gets placed in a writable\r
44# location.\r
45#LOGFILE=$HOME/.logs/mail/procmail.log\r
46\r
47# See the manpages `procmailrc' and `procmailex' for explanations\r
48# of the syntax involved.\r
49\r
50# The following 2 rules come before the spam rules because we\r
51# want to make sure that email from these people get through.\r
52# It's a form of whitelisting.\r
53\r
54# Stuff from the family\r
55:0\r
56* ^From.*(familymember1@msn|familymember2@yahoo)\r
57.Family/\r
58\r
59# Work-related\r
60:0\r
61* ^From.*person@somecollege\r
62.Work/\r
63\r
64# If mail hasn't been put through spamassassin, do so now\r
65:0 fW\r
66* !^X-Spam-Level:\r
67| spamc\r
68\r
69# All mail tagged as spam (eg. with a score higher than the set\r
70# threshold) is definitely spam.\r
71:0\r
72* ^X-Spam-Status: Yes\r
73.Spam.Definitely/\r
74\r
75# If it scores 3 or better, it's probably spam.\r
76:0\r
77* ^X-Spam-Level: \*\*\*\r
78.Spam.Probably/\r
79\r
80# The Debian Bug-Tracking System forwards me a copy of each bug report\r
81# I send in. Since I don't already have a copy of this report, put it\r
82# in my Sent box.\r
83:0\r
84* ^From:.*me@hcoop\.net\r
85* ^To:.*submit@bugs\.debian\.org\r
86.Sent/\r
87\r
88# Local mail (error messages and the like)\r
89:0\r
90* ^(To:|From).*local\.domain\.org\r
91.Local/\r
92\r
93# Vending stuff\r
94:0\r
95* ^To:.*me(\+|_)vending@domain\.org\r
96.Vending/\r
97\r
98# School-related\r
99:0\r
100* ^To:.*me\+school@domain\.org\r
101.School/\r
102\r
103# Crap sent to all students\r
104:0\r
105* ^(To|Cc):.*[Rr]-[Uu]sers_\r
106.Spam.Ignore/\r
107\r
108# Bug reports\r
109:0\r
110* ^(From|To|C[c]):.*(bugs\.debian\.org|bugzilla\.)\r
111.Bugs/\r
112\r
113# LifeReader mailing list\r
114:0\r
115* ^(From|To|C[c]):.*liferea-devel@lists\r
116.Lists.LifeRea/\r
117\r
118# Neki_Fujiyama (Samurai Pizza Cats) list\r
119:0\r
120* ^(From|To|C[c]):.*[Nn]eko_[Ff]ujiyama@yahoogroups\r
121.Lists.Neko_Fujiyama/\r
122\r
123# Hcoop mailing list\r
124:0\r
125* ^To:.*users@hcoop\r
126.Lists.HCoop/\r
127\r
128# InfoWorld newsletters\r
129:0\r
130* ^From.*@newsletter\.infoworld\r
131.Lists/\r
132\r
133# Other lists\r
134:0\r
135* ^(From|To|C[c]):.*(@lists\.|@yahoogroups)\r
136.Lists/\r
137\r
138# Anything I've sent should go to Test\r
139:0\r
140* ^From:.*(mwolson@|@mwolson\.org)\r
141.Test/\r
142}}}\r
143\r
144= Another Example =\r
145\r
146I 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.\r
147\r
148I 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.\r
149\r
150Note 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.\r
151\r
152{{{## JustinLeitgeb .procmailrc\r
153## Modified Sun Apr 15 01:41:34 EDT 2007\r
154\r
155# We use a maildir here at hcoop.net\r
156MAILDIR=$HOME/Maildir\r
157DEFAULT=$MAILDIR/\r
158\r
159# Create a log file\r
160LOGFILE=$HOME/.logs/mail/procmail.log\r
161\r
162# Make a backup of all mail that we'll wipe out when we're sure that \r
163# filtering is working correctly.\r
164:0 c \r
165.backup/\r
166\r
167## Filter all of the mailing lists that we get into different\r
168## folders.\r
169\r
170# CFP (call for papers) list\r
171:0\r
172* ^Sender.*owner-cfp@lists.sas.upenn.edu\r
173.lists.CFP/\r
174\r
175# plone-users\r
176:0\r
177* ^Sender.*plone-users-bounces@lists.sourceforge.net\r
178.lists.plone-users/\r
179\r
180# nflug\r
181:0\r
182* ^Sender.*nflug-bounces@nflug.org\r
183.lists.nflug/}}}\r