source: trunk/third/nmh/MAIL.FILTERING @ 12455

Revision 12455, 3.7 KB checked in by danw, 25 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r12454, which included commits to RCS files with non-trunk default branches.
Line 
1
2INTRODUCTION
3------------
4It is a common practice when using nmh to filter your inbound mail
5directly into nmh folders.  There are several programs which allow you
6to do this, of which two common ones are procmail and slocal.
7
8SLOCAL
9------
10The slocal command is part of the nmh distribution.  It is a fairly
11simple mail filtering program.  Check the slocal man page for an example
12filtering file (called .maildelivery).
13
14PROCMAIL
15--------
16Probably the most popular mail filtering command is procmail.  It can
17filter mail into standard mbox-style spool files, as well as into MH/nmh
18style folders.
19
20Although procmail knows how to put a message directly into an nmh folder,
21this is not recommended.  Procmail doesn't know about nmh sequences.
22Instead you should have procmail use the nmh command `rcvstore' to put
23the message into the folder.  The `rcvstore' command will (by default)
24add each new message to the "unseen" sequence, so you can detect new
25messages in folders with the `flist' command.
26
27Also, nmh commands generally like to keep mail messages in RFC-822
28format.  But by default, procmail will leave the first line of the
29message unchanged.  This line (which usually begins with "From ") is
30not in the standard RFC-822 format.  It is recommended that you use the
31command `formail' (which comes in the procmail distribution) to rewrite
32this line so that it begins with the header name "X-Envelope-From:".
33An example of how to do this is given below.
34
35The reason the header name "X-Envelope-From:" is recommended, is that the
36nmh command `packf' (as of version 0.23) will check for this header when
37packing folders.  The `packf' command knows how to undo the rewriting
38of the "From " line to the "X-Envelope-From:" line.  By checking for
39this header name, `packf' is able to pack the folder into exactly the
40form that is used if procmail delivers to the standard mail spool.
41
42If you do not rewrite the "From " line into this format, the `packf'
43command will still work.  But it may create fake "From " lines which
44are not the same as the originals.
45
46Here is a typical .procmailrc file for using procmail in conjunction
47with nmh.  For more information, see the manual pages for procmail,
48procmailrc and procmailex.
49
50###################################################################
51# .procmailrc
52###################################################################
53# To use procmail, put the next line in your .forward file:
54# "|IFS=' ' && exec /usr/local/bin/procmail -f- || exit 75 #XXX"
55# Do not remove the double quotes.  Change XXX to your username.
56# Edit path to procmail above, and the VARIABLES below, as needed.
57# Adapt the MAILING LIST section below for lists you subscribe to.
58# Your .forward needs to be world-readable, but not world-writable.
59###################################################################
60# This .procmailrc is written for use with nmh/mh/exmh/mh-e
61###################################################################
62
63### VARIABLES ###
64VERBOSE=off
65SHELL=/bin/sh
66PATH=/usr/local/nmh/lib:/usr/local/nmh/bin:/usr/bin:/usr/local/bin
67MAILDIR=$HOME/Mail
68LOGFILE=$MAILDIR/procmail.log
69LOCKEXT=.lock
70
71#################
72# CLEANUP MESSAGE
73#################
74
75# Force the "From user date" to become part of header
76:0 Whf
77| formail -z -R 'From ' X-Envelope-From:
78
79###############
80# MAILING LISTS
81###############
82
83:0 w: nmh-workers/$LOCKEXT
84* ^Resent-from: *nmh-workers
85| rcvstore +nmh-workers
86
87# catches exmh-{announce,users,workers}
88:0 w: exmh/$LOCKEXT
89* ^TOexmh
90| rcvstore +exmh
91
92# Catch junk.  Don't add it to "unseen" sequence (nmh only)
93:0 w: junk/$LOCKEXT
94* ^(reply-to|from|sender):.*(spammer|flamer|evil-host)
95| rcvstore -nounseen +junk
96
97################
98# DEFAULT ACTION
99################
100:0 w: inbox/$LOCKEXT
101| rcvstore +inbox
102
Note: See TracBrowser for help on using the repository browser.