nmh-workers
[Top] [All Lists]

information about filtering mail and exmh/nmh

1998-02-13 15:46:31
The following is a copy of the file MAIL.FILTERING that I'm
adding to the next nmh distribution.  It gives information about
how to correctly use procmail in conjunction with exmh and nmh.

Please send any comments or suggestions about this file to the
nmh mailing list (nmh-workers(_at_)math(_dot_)gatech(_dot_)edu).

rc

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 commons ones are procmail and 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).

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.

Here is a typical .procmailrc file for using procmail in conjunction
with nmh.

###################################################################
# .procmailrc
###################################################################
# To use procmail, put the next line in .forward
# "|IFS=' ' && exec /usr/local/bin/procmail -f- || exit 75 #coleman"
# The double quotes should not be removed.
# 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 -c -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

# Don't add junk to "unseen" sequence
:0 w: junk/$LOCKEXT
* ^TOjunk
| rcvstore -nounseen +junk

################
# DEFAULT ACTION
################
:0 w: inbox/$LOCKEXT
| rcvstore +inbox


<Prev in Thread] Current Thread [Next in Thread>