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