Annotation of 43BSDReno/share/doc/usd/08.mh/mhook.me, revision 1.1.1.1

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

unix.superglobalmegacorp.com

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