File: procmailrc-example

package info (click to toggle)
procmail-lib 1%3A1995.08.28-4
  • links: PTS
  • area: main
  • in suites: slink
  • size: 156 kB
  • ctags: 32
  • sloc: perl: 213; makefile: 141
file content (296 lines) | stat: -rw-r--r-- 8,930 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
# This is an annotated example ~/.procmailrc file
#
# Use it as a guide to creating your own ~/.procmailrc file.
#
#  You must edit this before installing it;
#  *** IT WILL NOT WORK AS IS ***.
#
# $Id: procmailrc-example,v 1.3 1995/08/24 20:34:05 aks Exp $
#
#    Copyright (C) 1995  Alan K. Stebbens <aks@hub.ucsb.edu>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
#
# It is a good idea to define SHELL to /bin/sh, so that no
# unexpected surprises occur.  Some systems redefine SHELL to
# your default login shell, which may not be a Bourne-shell compatible
# shell.  Since most procmail recipes use Bourne-shell language
# features, SHELL=/bin/sh is a good idea.

SHELL=/bin/sh

# Defining the path to include the directories where procmail is
# installed is necessary if the system default path doesn't include
# them.  Typically, ~/.procmailrc is invoked by procmail via
# sendmail, and the PATH may not be sufficient as it is.

PATH=$PATH:/usr/local/bin:/usr/local/mh/bin

# Defining MAILDIR does a "cd $MAILDIR".  So, define it to the
# directory which contains most of your mail recipes.  I use 
# $HOME/Mail.

MAILDIR=$HOME/Mail

# It is an important feature to keep a log of your mail -- just so you
# have some kind of idea what is happening to it.  Note that plain
# filenames are relative to MAILDIR, since procmail always sets the
# current directory to MAILDIR.  So, if you keep your recipe and log
# files in $MAILDIR, then you can name the files by their basename.

LOGFILE=Log

# I use FAILDROP to define a mail drop location which is on a 
# *different* filesystem than my $DEFAULT maildrop.  This allows
# me to write conditional recipes, which are invoked only if
# the $DEFAULT or other delivery fails.
FAILDROP=/other/spool.mail

# If you use MH as your MUA (as I do), then defining several
# folders here make it easy to globally change them later.
# MH folders are indicated by the trailing "/.".
INBOX=inbox/.
ADMIN=admin/.
OTHER=other/.
BADMAIL=errs/.

# I use this in many recipes to identify myself, and to 
# annotate filtered mail with "X-Loop: $MY_ADDR" headers as
# part of a loop detection algorithm.

MY_ADDR=myname@myhost.mydomain.dom

# I use $MY_NAMES variable to recognize the various aliases 
# which all lead to my incoming maildrop.  If you have an 
# AOL and Compuserve and Internet account all forwarded to 
# the same address, you would define this as the all of the 
# varying alternatives.

MY_NAMES="(First Mi. Lastname|First|Lastname|First\.Lastname|\
	   F.Lastname|FML)@(myhost\.mydomain\.dom|aol\.com|\
	   compuserv.com)

# Define FROMSIG to your standard "From:" signature line.

FROMSIG="First's Mailer-Daemon <$MY_ADDR>"


# I include "dupcheck.rc" to avoid duplicate incoming mail.  Note that
# this will not identify mail duplicated by different mailers, just
# duplicate mail from the same origin.

INCLUDERC=$LIB/dupcheck.rc


# Pull in the standard header patterns
INCLUDERC=$LIB/headers.rc


# If I am on vacation, I create a file called ~/Mail/vacation.msg 
# into which I place my notice explaining my absence.  This file
# is examined by "ackmail.rc" (see below).

# However, some of my other recipes below varying their behavior
# depending upon the value of $VACATION.  In vacation mode,
# more things get tossed than otherwise.

# So, set VACATION to "yes" in vacation mode
:0
* ? test -f vacation.msg
{ VACATION=yes }

# The rest of the recipe is broken into two basic parts:
#
#    a.  process mail if it is addressed *directly* to me,
#	 on either a "To:" or "Cc:" header.
#
#    b.  process other mail (mail to me via any mailing 
#	 lists of which I am a member).
#
#
# I like the variable $USER (since I grew up on a BSD system),
# so let's define it using the SysV equivalent (which procmail
# sets up).

USER=${USER:-$LOGNAME}

# If the mail is to me ($USER), do some special things
:0
* $ ^TO($USER)
{

    # First -- since I allow a selected set of commands
    # on the Subject: line, I use "commands.rc" to recognize
    # and perform them.

    # Check for any commands on the Subject line
    # (but only if commands.rc is present).
    :0 
    * ? test -f commands.rc
    { INCLUDERC=commands.rc }

    # I also like to have mail to me acknowledged, to I use
    # ackmail.rc.  Include it

    :0
    * ? test -f ackmail.rc
    { INCLUDERC=ackmail.rc }

    # So far, the mail is not a command, and it has been
    # acknowledged, so now we can safely file it away.

    # If the mail is directly to me, -> +inbox
    :0:
    $INBOX
	
	# If the drop to $INBOX failed, then let's try dropping
	# it into $DEFAULT (which is where it would have gone
	# our recipe hadn't tried filtering it).
	:0 e:
	$DEFAULT

	    # Well, the $DEFAULT drop didn't work, so let's try
	    # yet another filesystem.
	    :0 e:
	    $FAILDROP

}

# Okay -- mail below here came to me indirectly -- from some
# mailing list.

# In vacation mode, let's trash any root mail -- someone else 
# get's to worry about this

:0 h
* VACATION ?? yes
* ^(To|From):.*root([ ,>]|$)
/dev/null

# I've occasionally written an addition to this basic procmail
# recipe by writing small, special case filtering recipes.  I
# Then "include" them using the method below.  This allows me
# to later disable the special case filtering by removing the
# file, or moving it to another name.

# A common special case is where you develop a group of 
# users who share a common interest for a while.  I then
# write such a small recipe to detect the incoming mail of interest
# and redirect it to these interested users.  A kind of
# "home brew" mailng list. 
#
# This way, I can share the mail to me by relaying it to them without
# having to inform (and educate) them about mailing lists.  Typically,
# some of these users are either adminstrative types or highly
# non-technical types who do not wish to learn about mailing lists, but
# do wish to share in the mail of interest.

# This is only a short term solution -- setting up a mailing
# list is the proper thing to do for longer term distributions.

:0
* ? test -f mac-users.rc
{ INCLUDERC=mac-users.rc }

# I treat junkmail filtering as a "special case", and keep it
# in a separate file.  Basically, all the mail delivered in
# this file goes to /dev/null.

:0
* ? test -f junkmail.rc
{ INCLUDERC=junkmail.rc }

# Here's an example of a piece of mail which you might
# wish to have printed regularly when it arrives, and
# even auto-filed, but still show up in your +inbox for
# online perusal.

# Check on edupage; automatically print it (unless I'm on vacation)
# and auto-file it.  Leave it also in my inbox to be read and deleted.
:0
* ^Sender: *owner-edupage
* ^To:.*\<edupage@.*\.educom\.edu
* ^Subject: *Edupage
{

  # File it into its proper place (use "c" to "copy" the mail)
  :0c:
   info/edupage/.

  LOCATION=$LASTFOLDER
  
  # If I'm not on vacation, print the thing automatically
  :0
  * ! VACATION ?? yes
  * ! ^X-Printed:
  {
    # Mark it as printed (so I don't print it twice)
    :0fh
    | formail -I"X-Printed: `date`"

    # Here I print it using a special shell script called "printmail"
    # which is a little wrapper around "enscript", using "-b" to
    # set the mailbox name, and -i to set the subject.
    :0c
    | sh -c "PRINTER=ps; export PRINTER ; $HOME/bin/printmail $LOCATION"
  }
}

# On vacation, trash these

:0
* VACATION ?? yes
* ^TO(((help|info|bug)-)?gnu-(emacs|utils|([0-9a-zA-Z]+-)?sources)(-bug)?|\
	mh-users|com-priv-digest-dist|amd-workers|edb-list|sybase-l)@
/dev/null

# If it is mail to one my lists, put into +other
:0:
* ^TO(((help|info|bug)-)?gnu-(emacs|utils|([0-9a-zA-Z]+-)?sources)(-bug)?|\
	mh-users|procmail|SmartList|MailAgent|Majordomo(-(users|workers))?|\
	list-managers|com-priv-digest-dist|amd-workers|req|edb-list|\
	perl-users|sybase-l|(info-)?ietf(-announce(-request)?)?)(:;)?@
$OTHER
    :0e:
    $DEFAULT
	:0e:
	$FAILDROP


# When I'm on vacation, throw mailer-daemon errors away (someone
# else has to deal with it).

:0 h
* VACATION ?? yes
* ^FROM_MAILER
/dev/null

# If mail is from some kind of daemon, drop it in the +admin folder
:0:
* ^FROM_MAILER
$ADMIN
    :0e:
    $DEFAULT
	:0e:
	$FAILDROP

# Drop any remaining into my $INBOX
:0:
$INBOX
    :0e:
    $DEFAULT
	:0e:
	$FAILDROP