Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ slocal(1mh) — Ultrix/UWS 4.1 RISC

Media Vault

Software Library

Restoration Projects

Artifacts Sought

slocal(1mh)

Name

slocal − MH receive-mail hooks

Syntax

slocal $HOME/.maildelivery [−form formfile] [switches for postproc] address ...  [−help]
/usr/new/lib/mh/rcvpack file [−help]
/usr/new/lib/mh/rcvtty [command ...] [−help]

Description

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 line:

| /usr/new/lib/mh/slocal −user $USER

in your .forward file in your home directory.

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

where

field:
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:

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 field. Matching is case-insensitive but not RE-based.
 

action:
The action to take to deliver the message. This is one of
 

file or >:
Append the message to the file named by string using the standard maildrop delivery process.  If the message can be appended to the file, then this action succeeds. 
 
When writing to the file, a new field is added:
 

Delivery-Date: date
 
which indicates the date and time that the message was appended to the file.
 

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 variables:

$(sender): the return address for the message
$(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): miscellaneous out-of-band information

When a process is invoked, its environment is as follows: The user/group id’s are set to recipient’s id’s
The working directory is the recipient’s 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
No other envariables exist. The process is given a certain amount of time to execute. If the process does not exit within this limit, it will be terminated. The amount of time is calculated as ((size times 60) plus 300) seconds, where size is the number of bytes in the message. The exit status of the process is consulted to determine the success of the action. An exit status of zero means that the action succeeded. Any other exit status (or abnormal termination) means that the action failed. 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 continue on, doing whatever it wanted for as long as it wanted.  This approach should only be used if you do not care about the outcome of the action; because the success or failure of the child process cannot be passed back to slocal. However, if the parent is going to return a non−zero exit status, then this approach can lead to quicker delivery into your maildrop.

qpipe or <caret>:
Similar to pipe, but executes the command directly, after built-in variable expansion, without assistance from the shell. 

destroy:
This action always succeeds.

result:
Indicates how the action should be performed:
 

A:
Perform the action. If the action succeeded, then the message is considered delivered.

R:
Perform the action. Regardless of the outcome of the action, the message is not considered delivered.

?:
Perform the action only if the message has not been delivered. If the action succeeded, then the message is considered delivered.

 
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/new/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 white space or comma.  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 backslash. 

The following example 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 simply there to help you.  The code fragment precedes the explanation. 

 Code Fragment
-------------
 #fieldpatternactionresultstring
1)Tommdf2fileAmmdf2.log
2)FrommmdfpipeAerr-message-archive
3)Senderuk-mmdf-workersfile?mmdf2.log
4)ToUnix>Aunix-news
5)addrjpo=mmdf|Ammdf-redist
6)addrjpo=ack|R“resend −r $(reply-to)”
7)FromstevedestroyA−
8)default−>?mailbox
9)*−|Rrcvalert
 Commentary
---------------
 1) file mail with mmdf2 in the “To:” line into file mmdf2.log
2) Messages from mmdf pipe to the program err-message-archive
3) Anything with the “Sender:” address “uk-mmdf-workers”
3) file in mmdf2.log if not filed already
4) “To:” unix − put in file unix-news
5) if the address is jpo=mmdf − pipe into mmdf-redist
6) if the address is jpo=ack − send an acknowledgement copy back
7) anything from steve − destroy!
8) anything not matched yet − put into mailbox
9) always run rcvalert

Four programs are currently available, rcvdist (redistribute incoming messages to additional recipients), rcvpack (save incoming messages in a packf file), and rcvtty (notify user of incoming messages).  The fourth program, rcvstore is described on the rcvstore() reference page. They all reside in the /usr/new/lib/mh/ directory. 

The rcvdist program will resend 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(.).

The rcvpack program will append a copy of the message to the file listed on its command line. Its use is obsoleted by the .maildelivery.

The rcvtty 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 rcvtty will write the output to your terminal if, and only if, your terminal has “world-writable” permission. If no file is specified, or is bogus, etc., then the rcvtty program will give a one-line scan listing to the terminal access daemon.

Restrictions

For compatibility with older versions of MH, if slocal cannot find the user’s .maildelivery file, it will attempt to execute an old-style rcvmail hook in the user’s $HOME directory. In particular, it will first attempt to execute .mh_receive file maildrop directory user.  Failing that it will attempt to execute

$HOME/bin/rcvmail user file sender

before giving up and writing 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. 

Files

/usr/new/lib/mh/mtstailor tailor file
$HOME/.maildelivery The file controlling local delivery
/usr/new/lib/mh/maildelivery Rather than the standard file

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026