Annotation of 43BSD/contrib/mh/doc/mhook.me, revision 1.1.1.1

1.1       root        1: .\"    This file is automatically generated.  Do not edit!
                      2: .TH MHOOK 1 "April 22, 1986" MH [mh.6]
                      3: .UC 6
                      4: .SH NAME
                      5: mhook \- MH receive\-mail hooks
                      6: .SH SYNOPSIS
                      7: .in +.5i
                      8: .ti -.5i
                      9: $HOME/\&.maildelivery
                     10: .ds SL \fIslocal\fR
                     11: .ds ZS slocal
                     12: 
                     13: .ti .5i
                     14: /usr/new/lib/mh/rcvdist
                     15: \%[\-form\ formfile]
                     16: \%[switches\ for\ \fIpostproc\fR]
                     17: address\ ...
                     18: \%[\-help]
                     19: 
                     20: .ti .5i
                     21: /usr/new/lib/mh/rcvpack
                     22: file
                     23: \%[\-help]
                     24: 
                     25: .ti .5i
                     26: /usr/new/lib/mh/rcvtty
                     27: \%[command\ ...]
                     28: \%[\-help]
                     29: .in -.5i
                     30: .SH DESCRIPTION
                     31: A receive\-mail hook is a program that is run whenever you receive a
                     32: mail message.
                     33: You do \fBNOT\fR invoke the hook yourself,
                     34: rather the hook is invoked on your behalf by \fISendMail\fR,
                     35: when you include the line
                     36: .nf
                     37: .in +.5i
                     38:     \*(lq| /usr/new/lib/mh/slocal\*(rq
                     39: .in -.5i
                     40: .fi
                     41: in your \&.forward file in your home directory.
                     42: 
                     43: The \fI\&.maildelivery\fR file,
                     44: which is an ordinary ASCII file,
                     45: controls how local delivery is performed.
                     46: This file is read by \*(SL.
                     47: .if '\*(ZS'slocal' \{\
                     48: 
                     49: The format of each line in the \fI\&.maildelivery\fR file is
                     50: 
                     51: .ti +.5i
                     52: \fBfield pattern action result string\fR
                     53: 
                     54: where
                     55: 
                     56: .in +.5i
                     57: .ti -.25i
                     58: \fBfield\fR:
                     59: .br
                     60: The name of a field that is to be searched for a pattern.
                     61: This is any field in the headers of the message that might be present.
                     62: In addition, the following special fields are also defined:
                     63: .in +.25i
                     64: \fIsource\fR: the out\-of\-band sender information
                     65: .br
                     66: \fIaddr\fR: the address that was used to cause delivery to the recipient
                     67: .br
                     68: \fIdefault\fR: this matches \fIonly\fR if the message hasn't been delivered yet
                     69: .br
                     70: \fI*\fR: this always matches
                     71: .in -.25i
                     72: 
                     73: .ti -.25i
                     74: \fBpattern\fR:
                     75: .br
                     76: The sequence of characters to match in the specified field.
                     77: Matching is case\-insensitive but not RE\-based.
                     78: 
                     79: .ti -.25i
                     80: \fBaction\fR:
                     81: .br
                     82: The action to take to deliver the message.
                     83: This is one of
                     84: 
                     85: .in +.5i
                     86: .ti -.5i
                     87: \fIfile\fR or \fI>\fR:
                     88: .br
                     89: Append the message to the file named by \fBstring\fR.
                     90: The standard maildrop delivery process is used.
                     91: If the message can be appended to the file,
                     92: then this action succeeds.
                     93: 
                     94: When writing to the file,
                     95: a new field is added:
                     96: 
                     97: .ti +.5i
                     98: Delivery\-Date:\ date
                     99: 
                    100: which indicates the date and time that message was appended to the file.
                    101: 
                    102: .ti -.5i
                    103: \fIpipe\fR or \fI|\fR:
                    104: .br
                    105: Pipe the message as the standard input to the command named by \fBstring\fR,
                    106: using the Bourne shell \fIsh\fR\0(1) to interpret the string.
                    107: Prior to giving the string to the shell,
                    108: it is expanded with the following built\-in variables:
                    109: .in +.25i
                    110: $(sender): the return address for the message
                    111: .br
                    112: $(address): the address that was used to cause delivery to the recipient
                    113: .br
                    114: $(size): the size of the message in bytes
                    115: .br
                    116: $(reply\-to): either the \*(lqReply\-To:\*(rq or \*(lqFrom:\*(rq field
                    117: of the message
                    118: .br
                    119: $(info): miscellaneous out\-of\-band information
                    120: .in -.25i
                    121: 
                    122: When a process is invoked, its environment is:
                    123: the user/group id:s are set to recipient's id:s;
                    124: the working directory is the recipient's directory;
                    125: the umask is 0077;
                    126: the process has no /dev/tty;
                    127: the standard input is set to the message;
                    128: the standard output and diagnostic output are set to /dev/null;
                    129: all other file\-descriptors are closed;
                    130: the envariables \fB$USER\fR, \fB$HOME\fR, \fB$SHELL\fR are set
                    131: appropriately,
                    132: and no other envariables exist.
                    133: 
                    134: The process is given a certain amount of time to execute.
                    135: If the process does not exit within this limit,
                    136: the process will be terminated with extreme prejudice.
                    137: The amount of time is calculated as ((size x 60) + 300) seconds,
                    138: where size is the number of bytes in the message.
                    139: 
                    140: The exit status of the process is consulted in determining the success of the
                    141: action.
                    142: An exit status of zero means that the action succeeded.
                    143: Any other exit status (or abnormal termination) means that the action failed.
                    144: 
                    145: In order to avoid any time limitations,
                    146: you might implement a process that began by \fIforking\fR.
                    147: The parent would return the appropriate value immediately,
                    148: and the child could continue on,
                    149: doing whatever it wanted for as long as it wanted.
                    150: This approach is somewhat risky if the parent is going to return an
                    151: exit status of zero.
                    152: If the parent is going to return a non\-zero exit status,
                    153: then this approach can lead to quicker delivery into your maildrop.
                    154: 
                    155: .ti -.5i
                    156: \fIqpipe\fR or \fI<caret>\fR:
                    157: .br
                    158: Similar to \fIpipe\fR,
                    159: but executes the command directly,
                    160: after built\-in variable expansion,
                    161: without assistance from the shell.
                    162: 
                    163: .ti -.5i
                    164: \fIdestroy\fR:
                    165: .br
                    166: This action always succeeds.
                    167: .in -.5i
                    168: 
                    169: .ti -.25i
                    170: \fBresult\fR:
                    171: .br
                    172: Indicates how the action should be performed:
                    173: 
                    174: .in +.5i
                    175: .ti -.5i
                    176: \fIA\fR:
                    177: .br
                    178: Perform the action.
                    179: If the action succeeded, then the message is considered delivered.
                    180: 
                    181: .ti -.5i
                    182: \fIR\fR:
                    183: .br
                    184: Perform the action.
                    185: Regardless of the outcome of the action,
                    186: the message is not considered delivered.
                    187: 
                    188: .ti -.5i
                    189: \fI?\fR:
                    190: .br
                    191: Perform the action only if the message has not been delivered.
                    192: If the action succeeded, then the message is considered delivered.
                    193: .in -.5i
                    194: .in -.5i
                    195: 
                    196: The file is always read completely,
                    197: so that several matches can be made and several actions can be taken.
                    198: The \fI\&.maildelivery\fR file must be owned either by the user or by root,
                    199: and must be writable only by the owner.
                    200: If the \fI\&.maildelivery\fR file can not be found,
                    201: or does not perform an action which delivers the message,
                    202: then the file /usr/new/lib/mh/maildelivery is read according to the same rules.
                    203: This file must be owned by the root and must be writable only by the root.
                    204: If this file can not be found
                    205: or does not perform an action which delivers the message,
                    206: then standard delivery to the user's maildrop, /usr/spool/mail/$USER, is performed.
                    207: 
                    208: Arguments in the \fI\&.maildelivery\fR file are separated by white\-space or
                    209: comma.
                    210: Since double\-quotes are honored,
                    211: these characters may be included in a single argument by enclosing the
                    212: entire argument in double\-quotes.
                    213: A double\-quote can be included by preceeding it with a backslash.
                    214: 
                    215: To summarize, here's an example:
                    216: 
                    217: .nf
                    218: .in +.5i
                    219: .ta \w'default  'u +\w'uk-mmdf-workers  'u +\w'action  'u +\w'result  'u
                    220: #\fIfield\fR   \fIpattern\fR   \fIaction\fR    \fIresult\fR    \fIstring\fR
                    221: # lines starting with a '#' are ignored, as are blank lines
                    222: #
                    223: # file mail with mmdf2 in the \*(lqTo:\*(rq line into file mmdf2.log
                    224: To     mmdf2   file    A       mmdf2.log
                    225: # Messages from mmdf pipe to the program err-message-archive
                    226: From   mmdf    pipe    A       err-message-archive
                    227: # Anything with the \*(lqSender:\*(rq address \*(lquk-mmdf-workers\*(rq
                    228: # file in mmdf2.log if not filed already
                    229: Sender uk-mmdf-workers file    ?       mmdf2.log
                    230: # \*(lqTo:\*(rq unix \- put in file unix-news
                    231: To     Unix    >       A       unix-news
                    232: # if the address is jpo=mmdf \- pipe into mmdf-redist
                    233: addr   jpo=mmdf        |       A       mmdf-redist
                    234: # if the address is jpo=ack \- send an acknowledgement copy back
                    235: addr   jpo=ack |       R       \*(lqresend\0\-r\0$(reply-to)\*(rq
                    236: # anything from steve \- destroy!
                    237: From   steve   destroy A       \-
                    238: # anything not matched yet \- put into mailbox
                    239: default        \-      >       ?       mailbox
                    240: # always run rcvalert
                    241: *      \-      |       R       rcvalert
                    242: .re
                    243: .in -.5i
                    244: .fi
                    245: .\}
                    246: .if '\*(ZS'mmdfII' \{\
                    247: See \fImaildelivery\fR\0(5) for the details.
                    248: .\}
                    249: 
                    250: Four programs are currently standardly available,
                    251: \fIrcvdist\fR (redistribute incoming messages to additional recipients),
                    252: \fIrcvpack\fR (save incoming messages in a \fIpackf\fR'd file),
                    253: and \fIrcvtty\fR (notify user of incoming messages).
                    254: The fourth program,
                    255: \fIrcvstore\fR\0(1) is described separately.
                    256: They all reside in the \fI/usr/new/lib/mh/\fR directory.
                    257: 
                    258: The \fIrcvdist\fR program will resend a copy of the message to all of the
                    259: addresses listed on its command line.
                    260: It uses the format string facility described in \fImh\-format\fR\0(5).
                    261: 
                    262: The \fIrcvpack\fR program will append a copy of the message to the file listed
                    263: on its command line.
                    264: Its use is obsoleted by the \fI\&.maildelivery\fR.
                    265: 
                    266: The \fIrcvtty\fR program executes the named file with the message as its
                    267: standard input,
                    268: and gives the resulting output to the terminal access daemon for display
                    269: on your terminal.
                    270: If the terminal access daemon is unavailable on your system,
                    271: then \fIrcvtty\fR will write the output to your terminal
                    272: if, and only if, your terminal has \*(lqworld\-writable\*(rq permission.
                    273: If no file is specified, or is bogus, etc.,
                    274: then the \fIrcvtty\fR program will give a one\-line scan listing
                    275: to the terminal access daemon.
                    276: .Fi
                    277: ^/usr/new/lib/mh/mtstailor~^tailor file
                    278: ^$HOME/\&.maildelivery~^The file controlling local delivery
                    279: ^/usr/new/lib/mh/maildelivery~^Rather than the standard file
                    280: .Sa
                    281: .if '\*(ZS'slocal' \{\
                    282: rcvstore (1)
                    283: .\}
                    284: .if '\*(ZS'mmdfII' \{\
                    285: rcvstore (1), maildelivery(5)
                    286: .\}
                    287: .Co
                    288: None
                    289: .if '\*(ZS'slocal' \{\
                    290: .Hi
                    291: For compatibility with older versions of \fIMH\fR,
                    292: if \fIslocal\fR can't find the user's \fI\&.maildelivery\fR file,
                    293: it will attempt to execute an old\-style rcvmail hook in the user's $HOME
                    294: directory.
                    295: In particular,
                    296: it will first attempt to execute
                    297: 
                    298: .ti +.5i
                    299: \&.mh\(rureceive file maildrop directory user
                    300: 
                    301: failing that it will attempt to execute
                    302: 
                    303: .ti +.5i
                    304: $HOME/bin/rcvmail user file sender
                    305: 
                    306: before giving up and writing to the user's maildrop.
                    307: 
                    308: In addition,
                    309: whenever a hook or process is invoked,
                    310: file\-descriptor three (3) is set to the message in addition to the standard
                    311: input.
                    312: 
                    313: .\}
                    314: .Bu
                    315: Only two return codes are meaningful, others should be.
                    316: 
                    317: .if '\*(ZS'mmdfII' \{\
                    318: Versions of \fIMMDF\fR with the \fImaildelivery\fR mechanism aren't
                    319: entirely backwards\-compatible with earlier versions.
                    320: If you have an old\-style hook, the best you can do is to have a one\-line
                    321: \fI\&.maildelivery\fR file:
                    322: 
                    323: .ti +.15i
                    324: default \- pipe A \*(lqbin/rcvmail $(address) $(info) $(sender)\*(rq
                    325: .\}
                    326: .En

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.