MAILBOX(8)

NAME
mailbox - zmailer local delivery transport agent

SYNOPSIS
mailbox [ -8 ] [ -M ] [ -c channel ] [ -l logfile ] [ -Vabr ]

DESCRIPTION
mailbox is a ZMailer transport agent which is usually only run by the scheduler(8) program to deliver mail to local user mailbox files. The mailbox program must be run with root privileges and invoked with the same current directory as the scheduler, namely POSTOFFICE/scheduler.

Recipient addresses are processed as follows:

    - Strip backslashes.

    - Strip doublequotes around the address.

    - If the address starts with a '|', the rest of the recipient address string is interpreted as a shell command to be run.

    - If the address starts with a '/', the recipient address is a filename to append the message to.

    - Otherwise the recipient address must be a local user id.

    - If user is not found, and the first character of the address is a capital letter, the entire address is folded to lowercase and the user lookup is retried.

If delivering to a user mailbox (MAILBOX/userid) which doesn't exist, mailbox will try to create it. If the MAILBOX directory is mounted from a remote system this will succeed if the directory is group-writable.

Some sanity checks are done on deliveries to files and mailboxes:

    - The file being delivered to must have 1 link only, and must be either /dev/null or a regular file.

    - The file lock must be held.

Locking is normally done using the advisory flock(2) mechanism. If the MAILBOX directory is on a remote system, mailbox may have been compiled to use a remote locking service which will run flock on the MAILBOX server system on behalf of the local mailbox process. If flock(2) is not available, the fallback mechanism is lockf(2). Alternate locking methods include DOTLOCK (userid.lock) and on Sun't Solaris2 the MAILLOCK.

There is a further sanity check on mailbox deliveries, namely if the mailbox is not empty the mailbox program will enforce 2 newlines as a separator before the message to be delivered. This guarantees that User Agents, like Mail(1), can find the about-to-be delivered message even if the current contents of the mailbox is corrupt.

When delivering to a process (by starting a Bourne shell to execute a specified command line), the environment is set up to contain PATH, SHELL, HOME, USER, SENDER, and UID environment variables. The HOME and USER values are the recipient user's home directory and login id respectively. The SENDER value is the sender address for the message (as it would appear in a From_ line), and the UID value is the owner id of the process. The SIGINT and SIGHUP signals are ignored, but SIGTERM is treated normally. If the process dumps core, it will be retried later. Otherwise any non-zero exit status is taken as a permanent failure and will result in an error message back to the sender.

The actual data delivered to a file, mailbox, or process, is identical. It consists of the concationation of a UUCP style separator line, the message header specified in the message control file, and the message body from the original message file. The separator line starts with "From " and is followed by the sender address and a timestamp.

After all deliveries and just before exiting, the mailbox process will poke comsat(8C) in case recipients have turned on biff(1). The program may be compiled to look in the rwho files on the system for recipient names logged onto neighbouring hosts, in which case the comsat on the remote host will be poked. Even if this compile-time option is enabled, this will only be done for users that have a .rbiff file in their home directory.

OPTIONS

-c channel
    specifies which channel name should be keyed on. The default is local.

-l logfile
    specifies a logfile. Each entry is a line containing message id, pre-existing mailbox size in bytes, number of bytes appended, and the file name or command line delivered to.

-V  prints a version message and exits.

-a  the access time on mailbox files is, by default, preserved across delivery, so that programs such as login(1) can determine if new mail has arrived. This option disables the above action.

-b  disables biff notification.

-r  disables remote biff notification (if supported).

-8  enables MIME-QP-decoder to decode incoming MIME-email with Quoted-Printable encoded characters.

-M  enables the creation of MMDF-style mail-folder in the incoming mail folder. The default is "classic" UNIX-style folder.

INTERFACE
As all transport agents, the program reads relative pathnames of message control files from standard input (terminated with two linefeeds), and produces diagnostic output on the standard output. Normal diagnostic output is of the form:

	id/offset<TAB>notify-data<TAB>status message

where id is the inode number of the message file, offset is a byte offset within its control file where the address being reported on is kept, status is one of ok, error, or deferred, and the message is descriptive text associated with the report. The text is terminated by a linefeed. Any other format (as might be produced by subprocesses) is passed to standard output for logging in the scheduler log.

The exit status is a code from <sysexits.h>.

ENVIRONMENT
The default location for user mailbox files is currently /var/mail. This may be modified by setting the variable MAILBOX in /etc/zmailer.conf to the directory containing user mailbox files, for example /usr/spool/mail. This is best done in the ZMailer Config file.

FILES
/etc/zmailer.conf
/var/spool/postoffice (POSTOFFICE)
/var/mail (MAILBOX)

SEE ALSO
scheduler(8), comsat(8C), biff(1), flock(2), Mail(1)

AUTHOR
This program authored and copyright by:
Rayan Zachariassen <rayan@cs.toronto.edu>
Extensive modifications by:
Matti Aarnio <mea@nic.funet.fi>