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