Added all of the MH sources, including RCS files, in
[mmh] / docs / historical / mh-6.8.5 / conf / doc / maildelivery.5
1 .tr ~
2 .de NP
3 .IP "\fI\\$1\fP" 10
4 ..
5 .de II
6 .nr P- \\n()P    \" save the preceeding IP space
7 .nr )P 0        \" now set it to 0
8 .NP "\\$1\fP"
9 .nr )P \\n(P-    \" restore the preceeding IP space
10 ..
11 .ds M \fI.maildelivery\fP
12 .TH MAILDELIVERY 5 "1 October, 1985"
13 .SH NAME
14 maildelivery
15 .SH SYNOPSIS
16 User delivery specification file
17 .SH DESCRIPTION
18 The delivery of mail by the local channel can run through various
19 courses, including using a user tailorable file.
20 The delivery follows the following strategy, giving up at any point
21 it considers the message delivered.
22 .RS
23 .IP "1)" 4
24 If the address indicates a pipe or file default
25 then that is carried out.
26 .IP "2)" 4
27 The file \*M
28 (or something similar) in the home directory is read if it exists
29 and the actions in it are followed.
30 .IP "3)" 4
31 A system-wide file is consulted next, such as
32 .I /usr/lib/maildelivery
33 and the actions are similar to 2.
34 .IP "4)" 4
35 If the message still hasn't been delivered, then it is put into
36 the user's normal mailbox 
37 .RI ( .mail
38 or
39 .IR mailbox )
40 depending on the system.
41 .RE
42 .PP
43 The format of the \*M file is
44 .RS
45 .B field
46 .I <FS>
47 .B pattern
48 .I <FS>
49 .B action
50 .I <FS>\r
51 .B result
52 .I <FS>
53 .B string
54 .RE
55 where
56 .br
57 .NP field
58 is name of a field that is to be searched for a pattern.
59 This is any header field that you might find in a message.
60 The most commonly used headers are usually
61 From, to, cc, subject and sender.
62 As well as the standard headers, there are some psuedo-headers
63 that are can also be used. These are :-
64 .RS
65 .II source
66 The out of band sender information. This is the address MMDF would
67 use for reporting delivery problems with the message.
68 .II addr
69 the address that was used to mail to you, normally 'yourname' or 
70 \&'yourname=string' (see below).
71 .II default
72 if the message hasn't been delivered yet, this field is matched.
73 .II *
74 this case is always true regardless of any other action.
75 .RE
76 .NP pattern
77 is some sequence of characters that may be matched in the
78 above
79 .IR field .
80 Case is not significant.
81 .IP \fIaction\fP 10
82 is one of the mail delivery actions supported by the
83 local channel.  Currently the supported actions are
84 .B file
85 or
86 .BR > ,
87 which
88 appends the message to the given file, with delimiters;
89 .B pipe
90 or
91 .BR | ,
92 which starts up a process with the message
93 as the standard input;
94 and
95 .B destroy
96 which throws the message away.
97 There is also
98 .B qpipe
99 or
100 .BR ^ ,
101 which fakes a pipe command and is quicker than the standard pipe,
102 but does not do header reformatting.
103 .br
104 For piped commands, the exit status of the command is significant.
105 An exit status of 0 implies that the command succeeded and everything
106 went well. An exit status of octal 0300-0377 indicates that a permanent
107 failure occured and the message should be rejected; these error codes
108 are given in mmdf.h. Any other exit
109 status indicates a temporary failure and the delivery attempt will
110 be aborted and restarted at a later time.
111 .NP result
112 is one of the letters A, R or ? which stand for
113 Accept, Reject and "Accept if not delivered yet".
114 They have the following effects:
115 .RS
116 .II A
117 If the result of this line's action is OK, then the message can be
118 considered delivered.
119 .II R
120 The message is not to be considered delivered by this action.
121 .II ?
122 This is equivalent to
123 .I A
124 except that the action is not carried
125 out if the message has already been accepted.
126 .RE
127 .PP
128 The file is always read completely so that several matches
129 can be made, and several actions taken.
130 As a security check, the \*M file must be owned by either
131 the user or root, and must not have group or general
132 write permission. In addition the system delivery file has the above
133 restrictions but must also be owned by root.
134 If the field specified does not need a pattern a dash (\-)
135 or similar symbol is usually inserted to show that the field is present
136 but not used.
137 The field separator character can be either a tab, space or comma (,).
138 These characters can be included in a string by quoting them with
139 double quotes (") (double quotes can be included with a backslash '\e').
140 .PP
141 MMDF treats local addresses which contain an equals sign ('=')
142 in a special manner.  Everything in a local address
143 from an equals sign to the '@' is ignored and passed on to the
144 local channel.  The local channel will make the entire string available
145 for matching against the
146 .I addr
147 string of the \*M file.
148 For example, if you were to
149 subscribe to a digest as "foo=digest@bar.NET",
150 .B submit
151 and the local channel will verify
152 that it is legal to deliver
153 to "foo", but then the entire string "foo=digest" will be available
154 for string matching against the \*M file for the
155 .B addr
156 field.
157 .SH ENVIRONMENT
158 The environment in which piped programs are run
159 contains a few standard features, specifically:
160 .ne 5
161 .sp
162 .nf
163 HOME is set to the user's home directory.
164 USER is set to the user's login name.
165 SHELL is set to the user's login shell (defaults to /bin/sh).
166 .sp
167 .fi
168 The default umask is set up to 077, this gives a very protective
169 creation mask.
170 Initgroups is called if the 4.2 version of UNIX is running.
171 If further requirements are needed, then a shell script
172 can be run first to set up more complex environments.
173 .PP
174 There are certain built-in variables that you can give to
175 a piped program.  These are
176 .IR $(sender) ,
177 .IR $(address) ,
178 .IR $(size) ,
179 .I $(reply-to)
180 and
181 .IR $(info) .
182 .I $(sender)
183 is set to the return address for the message.
184 .I $(address)
185 is set to the address that was used to mail to you, normally `yourname'
186 or `yourname=string'.
187 .I $(size)
188 is set to the size in bytes of this message.
189 .I $(reply-to)
190 is set to the Reply-To: field (or the From: field if the former is
191 missing) and so can be used for automatic replies.
192 .I $(info)
193 is the info field from the internal mail header and is probably only
194 of interest to the system maintainers.
195 .SH EXAMPLE
196 .PP
197 Here is a rough idea of what a \*M file looks like:
198 .ne 12
199 .nf
200 .sp
201 # lines \fIstarting\fP with a '#' are ignored.
202 # as are blank lines
203 # file mail with mmdf2 in the "To:" line into file mmdf2.log
204 To~~~~mmdf2~~~~file~~~~A~~~~mmdf2.log
205 # Messages from mmdf pipe to the program err-message-archive
206 From~~~~mmdf~~~~pipe~~~~A~~~~err-message-archive
207 # Anything with the "Sender:" address "uk-mmdf-workers"
208 # file in mmdf2.log if not filed already
209 Sender~~~~uk-mmdf-workers~~~~file~~~~?~~~~mmdf2.log
210 # "To:" unix \- put in file unix-news
211 To~~~~Unix~~~~>~~~~A~~~~unix-news
212 # if the address is jpo=mmdf \- pipe into mmdf-redist
213 Addr~~~~jpo=mmdf~~~~|~~~~A~~~~mmdf-redist
214 # if the address is jpo=ack \- send an acknowledgement copy back
215 Addr~~~~jpo=ack~~~~|~~~~R~~~~"resend~~\-r~~$(reply-to)"
216 # anything from steve \- destroy!
217 from~~~~steve~~~~destroy~~~~A~~~~\-
218 # anything not matched yet \- put into mailbox
219 default~~~~\-~~~~>~~~~?~~~~mailbox
220 # always run rcvalert
221 *~~~~\-~~~~|~~~~R~~~~rcvalert
222 .sp
223 .fi
224 .SH FILES
225 $HOME/.maildelivery
226 \- the file's normal location.
227 .br
228 /usr/lib/maildelivery \-
229 the system file. This should be protected against attack.  It
230 may contain contents such as:
231 .ne 4
232 .sp
233 .nf
234 default~~~~\-~~~~pipe~~~~A~~~~stdreceive
235 *~~~~\-~~~~|~~~~R~~~~ttynotify
236 .fi
237 .sp
238 This allows interfacing to non-standard mail systems,
239 ones that don't believe in delimiter-separated mailboxes.
240 .SH "SEE ALSO"
241 rcvtrip(1)
242 .SH BUGS
243 And why not?