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