SLOCAL(1) User Commands SLOCAL(1)
NAME
slocal - special local mail delivery
SYNOPSIS
/usr/local/mh/lib/slocal [address info sender]
[-addr address] [-info data] [-sender sender]
[-user username] [-mailbox mbox] [-file file]
[-maildelivery deliveryfile] [-verbose] [-noverbose] [-
debug] [-help]
DESCRIPTION
Slocal is a program designed to allow you to have your
inbound mail processed according to a complex set of selec-
tion criteria. You do not normally invoke slocal yourself,
rather slocal is invoked on your behalf by your system's
Message Transfer Agent.
The message selection criteria used by slocal is specified
in the file .maildelivery in the user's home directory. The
format of this file is given below.
The message delivery address and message sender are deter-
mined from the Message Transfer Agent envelope information,
if possible. Under SendMail, the sender will obtained from
the UUCP "From " line, if present. The user may override
these values with command line arguments, or arguments to
the `-addr' and `-sender' switches.
The message is normally read from the standard input. The `
- file' switch sets the name of the file from which the mes-
sage should be read, instead of reading stdin. The `- user'
switch tells slocal the name of the user for whom it is
delivering mail. The `-mailbox' switch tells slocal the
name of the user's maildrop file.
The `-info' switch may be used to pass an arbitrary argument
to sub-processes which slocal may invoke on your behalf.
The `-verbose' switch causes slocal to give information on
stdout about its progress. The `-debug' switch produces
more verbose debugging output on stderr.
Message Transfer Agents
If your MTA is SendMail, you should include the line
"| /usr/local/mh/lib/slocal -user username"
in your .forward file in your home directory. This will
cause SendMail to invoke slocal on your behalf.
If your MTA is MMDF-I, you should (symbolically) link
/usr/local/mh/lib/slocal to the file bin/rcvmail in your
[mh.6] Last change: MH.6.8 1
SLOCAL(1) User Commands SLOCAL(1)
home directory. This will cause MMDF-I to invoke slocal on
your behalf with the correct "address info sender" argu-
ments.
If your MTA is MMDF-II, then you should not use slocal. An
equivalent functionality is already provided by MMDF-II; see
maildelivery(5) for details.
The Maildelivery File
The .maildelivery file controls how local delivery is per-
formed. Each line of this file consists of five fields,
separated by white-space or comma. Since double-quotes are
honored, these characters may be included in a single argu-
ment by enclosing the entire argument in double-quotes. A
double-quote can be included by preceding it with a
backslash. Lines beginning with `#' are ignored. The for-
mat of each line in the .maildelivery file is:
header pattern action result string
header:
The name of a header field that is to be searched for a
pattern. This is any field in the headers of the mes-
sage that might be present. The following special
fields are also defined:
source the out-of-band sender information
addr the address that was used to cause delivery
to the recipient
default this matches only if the message hasn't been
delivered yet
* this always matches
pattern:
The sequence of characters to match in the specified
header field. Matching is case-insensitive, but does
not use regular expressions.
action:
The action to take to deliver the message:
destroy This action always succeeds.
file or > Append the message to the file named by
string. The message is appended to the file
in the maildrop format which is used by your
message transport system. If the message can
be appended to the file, then this action
succeeds. When writing to the file, a
"Delivery-Date: date" header is added which
[mh.6] Last change: MH.6.8 2
SLOCAL(1) User Commands SLOCAL(1)
indicates the date and time that message was
appended to the file.
mbox Identical to file, but always appends the
message using the format used by packf (the
MMDF mailbox format).
pipe or | Pipe the message as the standard input to the
command named by string, using the Bourne
shell sh(1) to interpret the string. Prior
to giving the string to the shell, it is
expanded with the following built-in vari-
ables:
$(sender) the out-of-band sender information
$(address) the address that was used to cause
delivery to the recipient
$(size) the size of the message in bytes
$(reply-to) either the "Reply-To:" or "From:"
field of the message
$(info) the out-of-band information speci-
fied
qpipe or
Similar to pipe, but executes the command
directly, after built-in variable expansion,
without assistance from the shell. This
action can be used to avoid quoting special
characters which your shell might interpret.
result:
Indicates how the action should be performed:
A Perform the action. If the action succeeds,
then the message is considered delivered.
R Perform the action. Regardless of the out-
come of the action, the message is not con-
sidered delivered.
? Perform the action only if the message has
not been delivered. If the action succeeds,
then the message is considered delivered.
N Perform the action only if the message has
not been delivered and the previous action
succeeded. If this action succeeds, then the
message is considered delivered.
To summarize, here's an example:
#field pattern action result string
# lines starting with a '#' are ignored, as are blank lines
[mh.6] Last change: MH.6.8 3
SLOCAL(1) User Commands SLOCAL(1)
#
# file mail with mmdf2 in the "To:" line into file mmdf2.log
To mmdf2 file mmdfA2.log
# Messages from mmdf pipe to the program err-message-archive
From mmdf /bpiinp/eerr-meAssage-archive
# Anything with the "Sender:" address "mh-workers"
# file in mh.log if not filed already
Sender mh-workers file m?h_.log
# "To:" unix - put in file unix-news
To Unix > unixA-news
# if the address is jpo=ack - send an acknowledgement copy back
addr jpo=ack "/bi|n_/resendR-r $(reply-to)"
# anything from steve - destroy!
From steve destroy A-
# anything not matched yet - put into mailbox
default - > ma?i_lbox
# always run rcvtty
* - | /mh/liRb/rcvtty
The file is always read completely, so that several matches
can be made and several actions can be taken. The .mail-
delivery file must be owned either by the user or by root,
and must be writable only by the owner. If the .mail-
delivery file cannot be found, or does not perform an action
which delivers the message, then the file
/usr/local/mh/lib/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 is performed.
Sub-process environment
When a process is invoked, its environment is: the
user/group-ids are set to recipient's ids; the working
directory is the recipient's home directory; the umask is
0077; the process has no /dev/tty; the standard input is set
to the message; the standard output and diagnostic output
are set to /dev/null; all other file-descriptors are closed;
the envariables $USER, $HOME, $SHELL are set appropriately,
and no other envariables exist.
The process is given a certain amount of time to execute.
If the process does not exit within this limit, the process
will be terminated with extreme prejudice. The amount of
time is calculated as ((size x 60) + 300) seconds, where
size is the number of bytes in the message.
The exit status of the process is consulted in determining
the success of the action. An exit status of zero means
that the action succeeded. Any other exit status (or abnor-
mal termination) means that the action failed.
[mh.6] Last change: MH.6.8 4
SLOCAL(1) User Commands SLOCAL(1)
In order to avoid any time limitations, you might implement
a process that began by forking. The parent would return
the appropriate value immediately, and the child could con-
tinue on, doing whatever it wanted for as long as it wanted.
This approach is somewhat risky if the parent is going to
return an exit status of zero. If the parent is going to
return a non-zero exit status, then this approach can lead
to quicker delivery into your maildrop.
Duplicate Message Suppression
slocal is able to detect and supress duplicate messages. To
enable this, create two empty files in your $HOME directory:
.maildelivery.pag and .maildelivery.dir. These are ndbm
files which are used to store the Message-IDs of incoming
messages.
FILES
/usr/local/mh/lib/mtstailor MH tailor file
$HOME/.maildelivery The file controlling local delivery
/usr/local/mh/lib/maildelivery Rather than the standard file
/var/mail/$USER The default maildrop
SEE ALSO
rcvstore(1), mhook(1), mh-format(5)
DEFAULTS
`-noverbose'
`-maildelivery .maildelivery'
`-mailbox /var/mail/$USER'
`-file' defaults to stdin
`-user' defaults to the current user
CONTEXT
None
HISTORY
Slocal is designed to be backward-compatible with the mail-
delivery facility provided by MMDF-II. Thus, the .mail-
delivery file syntax is limited, as is the functionality of
slocal.
In addition to an exit status of zero, the MMDF values
RP_MOK (32) and RP_OK (9) mean that the message has been
fully delivered. Any other non-zero exit status, including
abnormal termination, is interpreted as the MMDF value
RP_MECH (200), which means "use an alternate route" (deliver
the message to the maildrop).
BUGS
Only two return codes are meaningful, others should be.
[mh.6] Last change: MH.6.8 5
SLOCAL(1) User Commands SLOCAL(1)
Slocal is designed to be backwards-compatible with the mail-
delivery functionality provided by MMDF-II.
Versions of MMDF with the maildelivery mechanism aren't
entirely backwards-compatible with earlier versions of MMDF.
If you have an MMDF-I old-style hook, the best you can do is
to have a one-line .maildelivery file:
default - pipe A "bin/rcvmail $(address) $(info)
$(sender)"
[mh.6] Last change: MH.6.8 6