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.
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).
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
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.
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.
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.
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.
46 Here is a typical .procmailrc file for using procmail in conjunction
47 with nmh. For more information, see the manual pages for procmail,
48 procmailrc and procmailex.
50 ###################################################################
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 ###################################################################
66 PATH=/usr/local/nmh/lib:/usr/local/nmh/bin:/usr/bin:/usr/local/bin
68 LOGFILE=$MAILDIR/procmail.log
75 # Force the "From user date" to become part of header
77 | formail -z -R 'From ' X-Envelope-From:
83 :0 w: nmh-workers/$LOCKEXT
84 * ^Resent-from: *nmh-workers
85 | rcvstore +nmh-workers
87 # catches exmh-{announce,users,workers}
92 # Catch junk. Don't add it to "unseen" sequence (nmh only)
94 * ^(reply-to|from|sender):.*(spammer|flamer|evil-host)
95 | rcvstore -nounseen +junk