INTRODUCTION ------------ It is a common practice when using nmh to filter your inbound mail directly into nmh folders. There are several programs which allow you to do this, of which two common ones are procmail and slocal. SLOCAL ------ The slocal command is part of the nmh distribution. It is a fairly simple mail filtering program. Check the slocal man page for an example filtering file (called .maildelivery). PROCMAIL -------- Probably the most popular mail filtering command is procmail. It can filter mail into standard mbox-style spool files, as well as into MH/nmh style folders. Although procmail knows how to put a message directly into an nmh folder, this is not recommended. Procmail doesn't know about nmh sequences. Instead you should have procmail use the nmh command `rcvstore' to put the message into the folder. The `rcvstore' command will (by default) add each new message to the "unseen" sequence, so you can detect new messages in folders with the `flist' command. Also, nmh commands generally like to keep mail messages in RFC-822 format. But by default, procmail will leave the first line of the message unchanged. This line (which usually begins with "From ") is not in the standard RFC-822 format. It is recommended that you use the command `formail' (which comes in the procmail distribution) to rewrite this line so that it begins with the header name "X-Envelope-From:". An example of how to do this is given below. The reason the header name "X-Envelope-From:" is recommended, is that the nmh command `packf' (as of version 0.23) will check for this header when packing folders. The `packf' command knows how to undo the rewriting of the "From " line to the "X-Envelope-From:" line. By checking for this header name, `packf' is able to pack the folder into exactly the form that is used if procmail delivers to the standard mail spool. If you do not rewrite the "From " line into this format, the `packf' command will still work. But it may create fake "From " lines which are not the same as the originals. Alternatively, you might be able to suppress generation of the "From " line. If your procmail invocation includes the -f or -r option, remove. Those options add a "From " line to incoming beginning of messages that do not have them. Here is a typical .procmailrc file for using procmail in conjunction with nmh. For more information, see the manual pages for procmail, procmailrc and procmailex. ################################################################### # .procmailrc ################################################################### # To use procmail, put the next line in your .forward file: # "|IFS=' ' && exec /usr/local/bin/procmail -f- || exit 75 #XXX" # Do not remove the double quotes. Change XXX to your username. # Edit path to procmail above, and the VARIABLES below, as needed. # Adapt the MAILING LIST section below for lists you subscribe to. # Your .forward needs to be world-readable, but not world-writable. ################################################################### # This .procmailrc is written for use with nmh/mh/exmh/mh-e ################################################################### ### VARIABLES ### VERBOSE=off SHELL=/bin/sh PATH=/usr/local/nmh/lib:/usr/local/nmh/bin:/usr/bin:/usr/local/bin MAILDIR=$HOME/Mail LOGFILE=$MAILDIR/procmail.log LOCKEXT=.lock ################# # CLEANUP MESSAGE ################# # Force the "From user date" to become part of header :0 Whf | formail -z -R 'From ' X-Envelope-From: ############### # MAILING LISTS ############### :0 w: nmh-workers/$LOCKEXT * ^Resent-from: *nmh-workers | rcvstore +nmh-workers # catches exmh-{announce,users,workers} :0 w: exmh/$LOCKEXT * ^TOexmh | rcvstore +exmh # Catch junk. Don't add it to "unseen" sequence (nmh only) :0 w: junk/$LOCKEXT * ^(reply-to|from|sender):.*(spammer|flamer|evil-host) | rcvstore -nounseen +junk ################ # DEFAULT ACTION ################ :0 w: inbox/$LOCKEXT | rcvstore +inbox