[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

Files Reference


.maildelivery File for MH

Purpose

Specifies actions to be taken when mail is received.

Description

The $HOME/.maildelivery file contains a list of actions the slocal command performs on received mail. The slocal command reads the $HOME/.maildelivery file and performs the specified actions when you activate it.

Specify your own mail delivery instructions in the $HOME/.maildelivery file. Each line in the $HOME/.maildelivery file describes an action and the conditions under which the action should be performed. The following five parameters must be present in each line of the file. These parameters are separated by either commas or space characters:
Field Pattern Action Result "String"

Blank lines in the .maildelivery file are ignored. A # (pound sign) in the first column indicates a comment. The file is read from beginning to end, so several matches can be made with several actions. The .maildelivery file should be owned by the user, and the owner can be the only one with write access.

If the $HOME/.maildelivery file cannot be found or does not deliver the message, the /etc/mh/maildelivery file is used in the same manner. If the message has still not been delivered, it is put in the user's mail drop. The default mail drop is the /usr/mail/$USER file.

The MH package contains four standard programs that can be run as receive-mail hooks: the rcvdist, rcvpack, rcvstore, and rcvtty commands.

Parameters


Field Specifies a header component to be searched for a pattern to match the Pattern parameter. Specify one of the following values for the Field parameter:

Component
Specify the header component you want to be searched; for example, From or cc.

*
Matches everything.

addr
Searches whatever field was used to deliver the message to you.

default
Matches only if the message has not been delivered yet.

Source
Specifies the out-of-band sender information.
Pattern Specifies the character string to search for in the header component given by the Field parameter. For example, if you specified From in the Field parameter, the Pattern parameter might contain an address like sarah@mephisto.

The Pattern parameter is not case-sensitive. The character string matches any combination of uppercase and lowercase characters. Specify a dummy pattern if you use an * (asterisk) or specify default in the Field parameter.

Action Specifies an action to take with the message if it contains the pattern specified in the Pattern parameter. Specify the following values:

file or >
Appends the message to the file specified with the "String" parameter. If the message can be written to the file, the action is considered successful. The Delivery-Date: header component is added to the message to indicate when the message was appended to the file.

pipe or |
Pipes the message as standard input to the command specified with the "String" parameter. The shell interprets the string. If the exit status from the command is 0, the action is considered successful. Prior to being given to the shell, the string is expanded with the following built-in variables:

$(Address)
Address used to deliver the message.

$(Size)
Size of the message in bytes.

$(reply-to)
Either the Reply-To: or From: header component of the message.

When a process is started with the pipe mechanism, the environment of the process is set as follows:

  • User and group IDs are set to the recipient's IDs.
  • Working directory is the recipient's directory.
  • The value of the umask variable is 0077.
  • Process has no /dev/tty special file.
  • Standard input is set to the message.
  • Standard output and diagnostic output are set to the /dev/NULL special file. All other file descriptors are closed. The $USER, $HOME, and $SHELL environmental variables are set appropriately; no other environment variables exist.

The formula for determining the amount of time the process is given to execute is:

bytes in message x 60 + 300 seconds.

After that time, the process is terminated.

If the exit status of the program is 0, it is assumed that the action succeeded. Otherwise, the action is assumed unsuccessful.

qpipe or ^
Acts similarly to pipe, but executes the command directly after built-in variable expansion without assistance from the shell. If the exit status from the command is 0, the action is successful.

destroy
Destroys the message. This action always succeeds.
Result Indicates how the action should be performed. You can specify one of the following values for this parameter:

A
Performs the action. If the action succeeds, the message is considered delivered.

R
Performs the action. Even if the action succeeds, the message is not considered delivered.

?
Performs the action only if the message has not been delivered. If the action succeeds, the message is considered delivered.
"String" Specifies the file to which the message can be appended if you use the file value for the Action parameter.

If you use the pipe or the qpipe value, the "String" parameter specifies the command to execute.

If you use the destroy value as the Action parameter, the "String" parameter is not used, but you must still include a dummy "String" parameter.

Note: To be notified that you have mail, you must specify the rcvtty command in the .maildelivery file.

Examples

  1. To save a message in a particular file, enter:

    From george file A george.mail
    

    This example directs the slocal command to search the From header line in messages. When the slocal command finds a message from george, it files the message in a file called george.mail.

  2. To save a copy of a message in a file, enter:

    addr manager > R proj_X/statlog
    

    This example directs the slocal command to search the address fields in messages. When it finds a message for the project manager, the slocal command files a copy of the message in a file called proj_X/statlog. The original message is not considered delivered (the R value), so the message is still treated as mail and you will be notified as usual.

  3. To be notified that you have received mail, enter:

    * - | R "/usr/lib/mh/rcvtty /home/sarah/allmail"
    

    In this example, the /home/sarah/allmail file contains the line:

    echo "You have mail\n"
    

    The /home/sarah/allmail file must have execute permission. When you have mail, the words You have mail are displayed on your console.

  4. To forward a copy of a message, enter:

    addr manager | A "/usr/lib/mh/rcvdist amy"
    

    This example directs the slocal command to search the address fields in messages. When it finds a message to the project manager, the slocal command sends a copy of the message to amy. The original message is not affected. The action is always performed (the A value). The command that the slocal command reads to distribute the copy to another user is the rcvdist command.

  5. To save any undelivered messages, enter:

    default - > ? mailbox
    

    This example directs the slocal command to find all undelivered messages. The - (dash) is a placeholder for the Pattern parameter. The > (greater than sign) instructs the slocal command to file the messages it finds. The ? (question mark) instructs the slocal command to respond only to undelivered messages. The name of the file to store undelivered messages is mailbox.

Implementation Specifics

This file is part of Message Handler in the Base Operating System.

Files


$HOME/.forward Searched by the sendmail command when mail is received, contains either the path of a machine to which to forward mail or a line to start the slocal command.
/usr/mail/$USER Provides the default mail drop.
/usr/lib/mh/slocal Contains the slocal command that reads the .maildelivery file.
/etc/mh/maildelivery Contains the mail delivery instructions that the slocal command reads if none are specified in the $HOME/.maildelivery file.
$HOME/.maildelivery Specifies mail-related actions for the slocal command to perform.

Related Information

The rcvdist command, rcvpack command, rcvstore command, rcvtty command, sendmail command, slocal command.

The mtstailor file.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]