slocal - MH receive-mail hooks
slocal $HOME/.maildelivery [-form formfile] [switches for postproc] address... [-help]
/usr/lib/mh/rcvpack file [-help]
/usr/lib/mh/rcvtty [command...] [-help]
A receive-mail hook is a program that is run whenever you receive a mail message. You do not invoke the hook yourself; it is invoked on your behalf by sendmail, when you include the following line in your .forward file in your home directory:
"| /usr/lib/mh/slocal -user username"
The .maildelivery file, which is an ordinary ASCII file, controls how local delivery is performed. This file is read by slocal.
The format of each line in the .maildelivery file is:
field pattern action result string
These components are explained below: The name of a field that is to be searched for a pattern. This is any field in the headers of the message that might be present. In addition, the following special fields are also defined:
The file is always read completely, so that several matches can be made and several actions can be taken. The .maildelivery file must be owned either by the user or by root, and must be writable only by the owner. If the .maildelivery file cannot be found, or does not perform an action which delivers the message, then the file /usr/lib/mh/maildelivery is read according to the same rules. This file must be owned by the root and must be writable only by the root. If this file cannot be found or does not perform an action which delivers the message, then standard delivery to the user's maildrop, /usr/spool/mail/$USER, is performed.
Arguments in the .maildelivery file are separated by a comma (,) or by white space. Since double quotes are honored, these characters may be included in a single argument by enclosing the entire argument in double quotes ("). A double quote can be included by preceding it with a back-slash.
Four programs are currently available: rcvdist redistributes incoming messages to additional recipients; rcvpack saves incoming messages in a packf(1) file; and rcvtty notifies the user of incoming messages. The fourth program, rcvstore, is described in the rcvstore(1) reference page. They all reside in the /usr/lib/mh directory.
The rcvdist program resends a copy of the message to all of the addresses listed on its command line. It uses the format string facility described in mh-format(4).
The rcvpack program appends a copy of the message to the file listed on its command line. It is made obsolete by .maildelivery.
program executes the named file with the
message as its standard input, and gives the resulting output to the terminal
access daemon for display on your terminal. If the terminal access daemon
is unavailable on your system, then
writes the output
to your terminal, only if your terminal has world-writable permission. If
no valid file is specified, then
gives a one-line
scan listing to the terminal access daemon.
For compatibility with older versions of MH, if slocal cannot find the user's .maildelivery file, it attempts to execute an old-style rcvmail hook in the user's $HOME directory. Specifically, it first attempts to execute the command:
.mh_receive file maildrop directory user
Failing that it attempts to execute:
$HOME/bin/rcvmail user file sender
If both of these fail, it gives up and write to the user's maildrop.
In addition, whenever a hook or process is invoked, file-descriptor three (3) is set to the message in addition to the standard input.
Only two return codes are meaningful, others should be.
This section shows how slocal could be used.
In this example, line-by-line comments have been extracted from the code to aid readability of the example. The line numbers would not normally be in the code; they are there to help you. The code fragment precedes the explanation:
resend -r $(reply-to)
File mail with
line into file
are piped to the program
Take anything with the address
field, and file it in
mmdf2.log, if it has not already been filed by line 1.
Put messages addressed to
in the file
If the address is
jpo=mmdf, pipe the message
If the address is
jpo=ack, send an acknowledgement
Destroy anything from
Take anything that is not matched yet and put it into mailbox.
The system customization file.
The system default file controlling local delivery.
The user-supplied alternative to the system default file controlling