Remove not used code (JLR define)
[mmh] / man / slocal.man1
1 .\"
2 .\" %nmhwarning%
3 .\"
4 .TH SLOCAL %manext1% "%nmhdate%" MH.6.8 [%nmhversion%]
5 .SH NAME
6 slocal \- asynchronously filter and deliver new mail
7 .SH SYNOPSIS
8 .HP 5
9 .na
10 .B slocal
11 [address\ info\ sender]
12 .RB [ \-addr
13 .IR address ]
14 .RB [ \-info
15 .IR data ]
16 .RB [ \-sender
17 .IR sender ]
18 .RB [ \-user
19 .IR username ]
20 .RB [ \-mailbox
21 .IR mbox ]
22 .\" \%[\-home\ homedir]
23 .RB [ \-file
24 .IR file ]
25 .RB [ \-maildelivery
26 .IR deliveryfile ]
27 .RB [ \-verbose " | " \-noverbose ]
28 .RB [ \-debug ]
29 .RB [ \-Version ]
30 .RB [ \-help ]
31 .ad
32 .SH DESCRIPTION
33 .B Slocal
34 is a program designed to allow you to have your inbound
35 mail processed according to a complex set of selection criteria.
36 You do not normally invoke
37 .B slocal
38 yourself, rather
39 .B slocal
40 is invoked on your behalf by your system's Message Transfer Agent
41 (such as
42 .BR sendmail )
43 when the message arrives.
44 .PP
45 The message selection criteria used by
46 .B slocal is specified
47 in the file
48 .RI ` \&.maildelivery '
49 in the user's home directory.
50 You can specify an alternate file with the
51 .B \-maildelivery
52 .I file
53 option.  The syntax of this file is specified below.
54 .PP
55 The message delivery address and message sender are determined from
56 the Message Transfer Agent envelope information, if possible.
57 Under
58 .BR sendmail ,
59 the sender will obtained from the mbox
60 `From ' line, if present.  The user may override these
61 values with command line arguments, or arguments to the
62 .B \-addr
63 and
64 .B \-sender
65 switches.
66 .PP
67 The message is normally read from the standard input.  The
68 .B \-file
69 switch sets the name of the file from which the message should be
70 read, instead of reading stdin.  This is useful when debugging a
71 .RI ` \&.maildelivery '
72 file.
73 .PP
74 The
75 .B \-user
76 switch tells
77 .B slocal
78 the name of the user for
79 whom it is delivering mail.  The
80 .B \-mailbox
81 switch tells
82 .B slocal
83 the name of the user's maildrop file.
84 .PP
85 The
86 .B \-info
87 switch may be used to pass an arbitrary argument to
88 sub-processes which
89 .B slocal
90 may invoke on your behalf.
91 .PP
92 The
93 .B \-verbose
94 switch causes
95 .B slocal
96 to give information on
97 stdout about its progress.  The
98 .B \-debug
99 switch produces more
100 verbose debugging output on stderr.  These flags are useful when
101 creating and debugging your
102 .RI ` \&.maildelivery '
103 file, as they
104 allow you to see the decisions and actions that
105 .B slocal
106 is taking, as well as check for syntax errors in your
107 .RI ` \&.maildelivery '
108 file.
109
110 .SS "Message Transfer Agents"
111 Most modern MTAs including
112 .BR sendmail ,
113 .BR postfix
114 and
115 .BR exim
116 support a \&.forward file for directing incoming mail.
117 You should include the line
118 .PP
119 .RS 5
120 `|\ %bindir%/slocal\ \-user\ username'
121 .RE
122 .PP
123 in your \&.forward file in your home directory.  This will cause
124 your MTA to invoke
125 .B slocal
126 on your behalf when a message arrives.
127
128 .SS "The Maildelivery File"
129 The
130 .RI ` \&.maildelivery '
131 file controls how
132 .B slocal
133 filters and delivers
134 incoming mail.  Each line of this file consists of five fields, separated
135 by white-space or comma.  Since double-quotes are honored, these
136 characters may be included in a single argument by enclosing the entire
137 argument in double-quotes.  A double-quote can be included by preceding it
138 with a backslash.  Lines beginning with `#' and blank lines are ignored.
139 .PP
140 The format of each line in the
141 .RI ` \&.maildelivery '
142 file is:
143 .PP
144 .RS 5
145 .B "header      pattern action  result  string
146 .RE
147 .PP
148 .BR header :
149 .RS 5
150 The name of a header field (such as To, Cc,  or From) that is to
151 be searched for a pattern.  This is any field in the headers of
152 the message that might be present.
153 .PP
154 The following special fields are also defined:
155 .TP \w'defaultrrr'u
156 .I source
157 the out-of-band sender information
158 .TP \w'defaultrrr'u
159 .I addr
160 the address that was used to cause delivery to the recipient
161 .TP \w'defaultrrr'u
162 .I default
163 this matches
164 .B only
165 if the message hasn't been delivered yet
166 .TP \w'defaultrrr'u
167 .I *
168 this always matches
169 .RE
170 .PP
171 .BR pattern :
172 .RS 5
173 The sequence of characters to match in the specified header field.
174 Matching is case-insensitive, but does not use regular expressions.
175 .RE
176 .PP
177 .BR action :
178 .RS 5
179 The action to take to deliver the message.  When a message is delivered,
180 a `Delivery\-Date:\ date' header is added which indicates the date
181 and time that message was delivered.
182 .TP 4
183 .I destroy
184 This action always succeeds.
185 .TP 4
186 .IR file ", " mbox ", or " >
187 Append the message to the mbox file named by
188 .IR string .
189 This is handled by piping the message to the
190 .B mmh
191 program
192 .BR rcvpack .
193 If
194 .B rcvpack
195 returned successful, then this action succeeds.
196 .TP 4
197 .IR pipe " or " |
198 Pipe the message as the standard input to the command named by
199 .IR string ,
200 using the Bourne shell
201 .B sh
202 to interpret the string.
203 Prior to giving the string to the shell, it is expanded with the following
204 built-in variables:
205 .RS
206 .TP \w'zzreplyztozaaa'u
207 $(sender)
208 the out-of-band sender information
209 .TP \w'zzreplyztozaaa'u
210 $(address)
211 the address that was used to cause delivery to the recipient
212 .TP \w'zzreplyztozaaa'u
213 $(size)
214 the size of the message in bytes
215 .TP \w'zzreplyztozaaa'u
216 $(reply\-to)
217 either the `Reply\-To:' or `From:' field of the message
218 .TP \w'zzreplyztozaaa'u
219 $(info)
220 the out-of-band information specified
221 .RE
222 .TP 4
223 .IR qpipe " or " ^
224 Similar to
225 .IR pipe ,
226 but executes the command
227 directly, after built-in variable expansion, without assistance from
228 the shell.  This action can be used to avoid quoting special characters
229 which your shell might interpret.
230 .TP 4
231 .IR folder " or " +
232 Store the message in the
233 .B mh
234 folder named by
235 .IR string .
236 This is handled by piping the message to the
237 .B mmh
238 program
239 .BR rcvstore .
240 If
241 .B rcvstore
242 returned successful, then this action succeeds.
243 .RE
244 .PP
245 .BR result :
246 .RS 5
247 Indicates how the action should be performed:
248 .TP \w'Azzz'u
249 .I A
250 Perform the action.  If the action succeeds, then the message
251 is considered delivered.
252 .TP \w'Azzz'u
253 .I R
254 Perform the action. Regardless of the outcome of the action,
255 the message is not considered delivered.
256 .TP \w'Azzz'u
257 .I ?
258 Perform the action only if the message has not been delivered.
259 If the action succeeds, then the message is considered delivered.
260 .TP \w'Azzz'u
261 .I N
262 Perform the action only if the message has not been delivered
263 and the previous action succeeded.  If this action succeeds, then the
264 message is considered delivered.
265 .PP
266 The delivery file is always read completely, so that several matches
267 can be made and several actions can be taken.
268 .RE
269
270 .SS "Security of Delivery Files"
271 In order to prevent security problems, the
272 .RI ` \&.maildelivery '
273 file must be owned either by the user or by root, and must be
274 writable only by the owner.  If this is not the case, the file is
275 not read.
276 .PP
277 If the
278 .RI ` \&.maildelivery '
279 file cannot be found, or does not
280 perform an action which delivers the message, then
281 .B slocal
282 will check for a global delivery file at
283 .IR %etcdir%/maildelivery .
284 This file is read according to the same rules.  This file must be
285 owned by the root and must be writable only by the root.
286 .PP
287 If a global delivery file cannot be found or does not perform an
288 action which delivers the message, then standard delivery to the
289 user's maildrop is performed.
290
291 .SS "Example Delivery File"
292 To summarize, here's an example delivery file:
293 .PP
294 .nf
295 .ta \w'default  'u +\w'mh-workersxx 'uC +\w'destroy 'uC +\w'result 'u
296 #
297 # .maildelivery file for mmh's slocal
298 #
299 # Blank lines and lines beginning with a '#' are ignored
300 #
301 # FIELD   PATTERN   ACTION  RESULT  STRING
302 #
303
304 # File mail with foobar in the `To:' line into file foobar.log
305 To        foobar    file    A       foobar.log
306
307 # Pipe messages from coleman to the program message-archive
308 From      coleman   pipe    A       /bin/message-archive
309
310 # Anything to the `nmh-workers' mailing list is put in
311 # its own folder, if not filed already
312 To        nmh-workers  folder ?     nmh-workers
313
314 # Anything with Unix in the subject is put into
315 # the file unix-mail
316 Subject   unix      file    A       unix-mail
317
318 # I don't want to read mail from Steve, so destroy it
319 From      steve     destroy A       \-
320
321 # Put anything not matched yet into mailbox
322 default   \-        file    ?       mailbox
323 .fi
324
325 .SS "Sub-process environment"
326 When a process is invoked, its environment is: the user/group-ids are
327 set to recipient's ids; the working directory is the recipient's home
328 directory; the umask is 0077; the process has no /dev/tty; the standard
329 input is set to the message; the standard output and diagnostic output are
330 set to /dev/null; all other file-descriptors are closed; the environment
331 variables
332 .BR $USER ,
333 .BR $HOME ,
334 .B $SHELL
335 are set appropriately,
336 .B $PATH
337 is preserved, but no other environment variables exist.
338 .PP
339 The process is given a certain amount of time to execute.  If the process
340 does not exit within this limit, the process will be terminated with
341 extreme prejudice.  The amount of time is calculated as ((size / 60) +
342 300) seconds, where size is the number of bytes in the message (with
343 30 minutes the maximum time allowed).
344 .PP
345 The exit status of the process is consulted in determining the success
346 of the action.  An exit status of zero means that the action succeeded.
347 Any other exit status (or abnormal termination) means that the action
348 failed.
349 .PP
350 In order to avoid any time limitations, you might implement a process
351 that began by
352 .BR fork ()-ing.
353 The parent would return the appropriate
354 value immediately, and the child could continue on, doing whatever it
355 wanted for as long as it wanted.  This approach is somewhat risky if
356 the parent is going to return an exit status of zero.  If the parent is
357 going to return a non-zero exit status, then this approach can lead to
358 quicker delivery into your maildrop.
359
360 .SH FILES
361 .fc ^ ~
362 .nf
363 .ta \w'%etcdir%/ExtraBigFileName  'u
364 ^$HOME/\&.maildelivery~^The file controlling local delivery
365 ^%etcdir%/maildelivery~^Rather than the standard file
366 ^%mailspool%/$USER~^The default maildrop
367 .fi
368
369 .SH "SEE ALSO"
370 rcvdist(1), rcvpack(1), rcvstore(1), mh\-format(5)
371
372 .SH DEFAULTS
373 .nf
374 .RB ` \-noverbose '
375 .RB ` \-maildelivery "' defaults to $HOME/\&.maildelivery"
376 .RB ` \-mailbox "' deaults to %mailspool%/$USER"
377 .RB ` \-file "' defaults to stdin"
378 .RB ` \-user "' defaults to the current user"
379 .fi
380
381 .SH CONTEXT
382 .B slocal
383 does neither read nor change the context.
384 Nor does it read the user profile.
385
386 .SH HISTORY
387 .B Slocal
388 was originally designed to be backward-compatible with
389 the
390 .B maildelivery
391 facility provided by
392 .BR MMDF-II .
393 Thus, the
394 .RI ` \&.maildelivery '
395 file syntax is somewhat limited.  But
396 .B slocal
397 has been modified and extended, so that is it no longer compatible with
398 .BR MMDF-II .
399 .PP
400 In addition to an exit status of zero, the
401 .B MMDF
402 values
403 .B RP_MOK
404 (32) and
405 .B RP_OK
406 (9) mean that the message has been fully delivered.
407 Any other non-zero exit status, including abnormal termination, is
408 interpreted as the
409 .B MMDF
410 value
411 .B RP_MECH
412 (200), which means
413 `use an alternate route' (deliver the message to the maildrop).
414 .PP
415 The `suppress duplicates' function had been removed from slocal for
416 simplicity reasons.
417
418 .SH BUGS
419 Only two return codes are meaningful, others should be.
420 .PP
421 .B Slocal
422 was originally designed to be backwards-compatible with the
423 .B maildelivery
424 functionality provided by
425 .BR MMDF-II .