MHOOK(5,F) AIX Technical Reference MHOOK(5,F) ------------------------------------------------------------------------------- mhook PURPOSE Specifies actions to be taken when mail is received. DESCRIPTION An mhook (or receive-mail hook) is an action that is automatically performed when new mail is received through the Message Handling (MH) Package. Whenever you receive a new message, the sendmail command searches for the file .forward in your $HOME directory. sendmail pipes the new message to the slocal program when $HOME/.forward exists and contains the following line: | /usr/lib/mh/slocal The slocal program reads the file $HOME/.maildelivery and performs the actions specified in that file for each message being delivered. You can specify your own mail delivery instructions (or mhooks) in $HOME/.maildelivery. Each line in $HOME/.maildelivery describes an action and the conditions under which the action should be performed. Each line must contain five arguments separated by commas or space characters. These arguments are: field pattern action result string The following list describes each argument: field Specifies a header component field to be searched for a match to the character string specified in the pattern argument. You can specify one of the following values for the field argument: component Searches the specified header component. * Always matches. 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 argument. The pattern argument is not case sensitive. Thus, the character string matches any combination of upper case and lower case characters. You must specify a dummy pattern if you use "*" or default in the field argument. Processed November 7, 1990 MHOOK(5,F) 1 MHOOK(5,F) AIX Technical Reference MHOOK(5,F) action Specifies an action to take with the message if the message contains the pattern specified in the pattern argument. You can specify the following actions: file or > Appends the message to the file given by the string argument. If the message can be written to the file, the action is considered successful. When a message is appended to a file, the header component Delivery-Date: 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 named by the string argument, using the shell to interpret the string. If the exit status from the command is 0 (zero), the action is considered successful. Prior to giving the string to the shell, the string is expanded with the following built-in variables: $(sender) The return address for the message. $(address) The address that was used to deliver the message. $(size) The size of the message in bytes. $(reply-to) Either the Reply-To: or From: header component of the message. $(info) Miscellaneous out-of-band information. qpipe or ^ Similar 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 (zero), the action is successful. destroy Always succeeds. result Indicates how the action should be performed. You can specify one of the following values for this argument: A Performed 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 If you use file as the action argument, string specifies the file to which the message can be appended. If you use pipe or qpipe, string specifies the command to execute. If you use destroy as the action Processed November 7, 1990 MHOOK(5,F) 2 MHOOK(5,F) AIX Technical Reference MHOOK(5,F) argument, string is not used, but you must still include a dummy string argument. All five arguments must be present in each line of the file. Blank lines in .maildelivery are ignored. Put a # in the first column to indicate a comment. If .maildelivery cannot be found, or does not deliver the message, /usr/lib/mh/maildelivery is used in the same manner. If the message is still not delivered, it is delivered to the user's maildrop, $HOME/.newmail. MH contains four standard programs that can be run as receive-mail hooks: rcvdist, rcvpack, rcvstore, and rcvtty. AIX Operating System Commands Reference contains descriptions of these programs. EXAMPLE The following example shows some lines that can be specified as mhooks in $HOME/.maildelivery: # If the message is from George, save it. From george file A george.mail # If the message is to the project manager, save a copy in log. addr manager > R proj_X/statlog # and forward it to Amy addr manager | A "/usr/lib/mh/rcvdist amy" # Save any messages not delivered. default - > ? mailbox FILES $HOME/.forward The file searched by the sendmail command when mail is received. /usr/lib/mh/slocal The slocal program that, when specified in $HOME/.forward, reads the file $HOME/.maildelivery and performs the actions specified in that file for each message being processed. /usr/lib/mh/maildelivery The mail delivery instructions. $HOME/.forward, performs actions defined in $HOME/.maildelivery. $HOME/.maildelivery The file specifying receive-mail hooks for slocal to perform. RELATED INFORMATION The rcvdist, rcvpack, rcvstore, rcvtty, sendmail, and slocal commands in AIX Operating System Commands Reference. Processed November 7, 1990 MHOOK(5,F) 3 MHOOK(5,F) AIX Technical Reference MHOOK(5,F) The "Overview of the Message Handling Package" in Managing the AIX Operating System. Processed November 7, 1990 MHOOK(5,F) 4