MAILBOX(8)

NAME
mailbox - zmailer local delivery transport agent

SYNOPSIS
mailbox [ -8 ] [ -M ] [ -c channel ] [ -h localpart ] [ -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/transport.

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. (See below for a chapter about locks.)

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. (Unless an '-DRBIFF_ALWAYS' compile option is used.)

OPTIONS

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

-h "localpart"
    specifies which of the possible multiple recipients is to be picked this time. Default is "none", which selects all local channel recipients, however when the routing is done with scripts storing some tokens (other than "-") into the "host"-part, it is possible to process "host-wise", i.e. so that each user has his/her own lock-state, and not just everybody hang on the same lock(s)..

-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>.

LOCKS
Locking scheme used at the system is configurable at the runtime, and has separate parameters for mailboxes, and files. The data is configurable with zenv variable MBOXLOCKS at which following characters have meanins:

`:' Separates mailbox locks, and file-locks at the string. The left side has mailbox locks, and the right side has locks for other regular files. (Files with explicite paths defined.)

`.' For mailboxes only: Does ``dotlock'' (userid.lock), or (at Sun Solaris) maillock() mechanism.

`F' If the system has flock() system call, uses it to lock the entire file. (Ignored at systems without flock()!)

`L' If the system has lockf() system call, uses it to lock the entire file. (Ignored at systems without lockf()!)

Locks are acquired in the same order as the key characters are listed.

Default for the lockf() capable systems is:

MBOXLOCKS=".L:L"

You can choose insane combinations of lock mechanisms, which at some systems cause locks to fail always, like at Linux-2.0 series where program must not use both lockf() and flock() locks.

It is extremely important, that selected locking methods are same throughout the system at all programs trying to acquire locks on mail spools.

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.

Variable MBOXLOCKS is used to define locking schemes used for mailbox spool files, and separately for other regular files.

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>