1 | .\" |
---|
2 | .\" %nmhwarning% |
---|
3 | .\" $Id: slocal.man,v 1.1.1.1 1999-02-07 18:14:22 danw Exp $ |
---|
4 | .\" |
---|
5 | .\" include the -mh macro file |
---|
6 | .so %etcdir%/tmac.h |
---|
7 | .\" |
---|
8 | .TH SLOCAL %manext1% MH.6.8 [%nmhversion%] |
---|
9 | .SH NAME |
---|
10 | slocal \- asynchronously filter and deliver new mail |
---|
11 | .SH SYNOPSIS |
---|
12 | .in +.5i |
---|
13 | .ti -.5i |
---|
14 | %libdir%/slocal \%[address\ info\ sender] |
---|
15 | .na |
---|
16 | .br |
---|
17 | \%[\-addr\ address] |
---|
18 | \%[\-info\ data] |
---|
19 | \%[\-sender\ sender] |
---|
20 | .br |
---|
21 | \%[\-user\ username] |
---|
22 | \%[\-mailbox\ mbox] |
---|
23 | .\" \%[\-home\ homedir] |
---|
24 | \%[\-file\ file] |
---|
25 | .br |
---|
26 | \%[\-maildelivery\ deliveryfile] |
---|
27 | \%[\-verbose] \%[\-noverbose] |
---|
28 | .br |
---|
29 | \%[\-suppressdup] \%[\-nosuppressdup] |
---|
30 | \%[\-debug] |
---|
31 | .br |
---|
32 | \%[\-version] |
---|
33 | \%[\-help] |
---|
34 | .ad |
---|
35 | .in -.5i |
---|
36 | .SH DESCRIPTION |
---|
37 | \fISlocal\fP is a program designed to allow you to have your inbound |
---|
38 | mail processed according to a complex set of selection criteria. |
---|
39 | You do not normally invoke \fIslocal\fP yourself, rather \fIslocal\fP |
---|
40 | is invoked on your behalf by your system's Message Transfer Agent |
---|
41 | (such as sendmail) when the message arrives. |
---|
42 | |
---|
43 | The message selection criteria used by \fIslocal\fP is specified |
---|
44 | in the file \fI\&.maildelivery\fP in the user's home directory. |
---|
45 | You can specify an alternate file with the `\-maildelivery file' |
---|
46 | option. The syntax of this file is specified below. |
---|
47 | |
---|
48 | The message delivery address and message sender are determined from |
---|
49 | the Message Transfer Agent envelope information, if possible. |
---|
50 | Under \fIsendmail\fP, the sender will obtained from the UUCP |
---|
51 | \*(lqFrom\ \*(rq line, if present. The user may override these |
---|
52 | values with command line arguments, or arguments to the `\-addr' |
---|
53 | and `\-sender' switches. |
---|
54 | |
---|
55 | The message is normally read from the standard input. The `\-file' |
---|
56 | switch sets the name of the file from which the message should be |
---|
57 | read, instead of reading stdin. This is useful when debugging a |
---|
58 | \fI\&.maildelivery\fP file. |
---|
59 | |
---|
60 | The `\-user' switch tells \fIslocal\fP the name of the user for |
---|
61 | whom it is delivering mail. The `\-mailbox' switch tells \fIslocal\fP |
---|
62 | the name of the user's maildrop file. |
---|
63 | |
---|
64 | \fIslocal\fR is able to detect and suppress duplicate messages. |
---|
65 | To enable this, use the option `\-suppressdup'. \fIslocal\fR will |
---|
66 | keep a database containing the Message-ID's of incoming messages, |
---|
67 | in order to detect duplicates. Depending on your configuration, |
---|
68 | this database will be in either ndbm or Berkeley db format. |
---|
69 | |
---|
70 | The `\-info' switch may be used to pass an arbitrary argument to |
---|
71 | sub-processes which \fIslocal\fP may invoke on your behalf. |
---|
72 | |
---|
73 | The `\-verbose' switch causes \fIslocal\fP to give information on |
---|
74 | stdout about its progress. The `\-debug' switch produces more |
---|
75 | verbose debugging output on stderr. These flags are useful when |
---|
76 | creating and debugging your \fI\&.maildelivery\fP file, as they |
---|
77 | allow you to see the decisions and actions that \fIslocal\fR is |
---|
78 | taking, as well as check for syntax errors in your \fI\&.maildelivery\fP |
---|
79 | file. |
---|
80 | |
---|
81 | .Uh "Message Transfer Agents" |
---|
82 | If your MTA is \fIsendmail\fP, you should include the line |
---|
83 | .sp |
---|
84 | .nf |
---|
85 | .in +.5i |
---|
86 | \*(lq|\ %libdir%/slocal\ \-user\ username\*(rq |
---|
87 | .in -.5i |
---|
88 | .fi |
---|
89 | .sp |
---|
90 | in your \&.forward file in your home directory. This will cause |
---|
91 | \fIsendmail\fP to invoke \fIslocal\fP on your behalf when a |
---|
92 | message arrives. |
---|
93 | |
---|
94 | If your MTA is \fIMMDF-I\fP, you should (symbolically) link |
---|
95 | %libdir%/slocal to the file bin/rcvmail in your home directory. This will |
---|
96 | cause \fIMMDF-I\fP to invoke \fIslocal\fP on your behalf with the correct |
---|
97 | \*(lq\fIaddress\ info\ sender\fP\*(rq arguments. |
---|
98 | |
---|
99 | If your MTA is \fIMMDF-II\fP, then you should not use \fIslocal\fP. |
---|
100 | An equivalent functionality is already provided by \fIMMDF-II\fP; see |
---|
101 | maildelivery(5) for details. |
---|
102 | |
---|
103 | .Uh "The Maildelivery File" |
---|
104 | |
---|
105 | The \fI\&.maildelivery\fR file controls how slocal filters and delivers |
---|
106 | incoming mail. Each line of this file consists of five fields, separated |
---|
107 | by white-space or comma. Since double-quotes are honored, these |
---|
108 | characters may be included in a single argument by enclosing the entire |
---|
109 | argument in double-quotes. A double-quote can be included by preceding it |
---|
110 | with a backslash. Lines beginning with `#' and blank lines are ignored. |
---|
111 | |
---|
112 | The format of each line in the \fI\&.maildelivery\fR file is: |
---|
113 | |
---|
114 | \fBheader pattern action result string\fR |
---|
115 | .sp |
---|
116 | .in +.5i |
---|
117 | .ti -.5i |
---|
118 | \fBheader\fP: |
---|
119 | .br |
---|
120 | The name of a header field (such as To, Cc, or From) that is to |
---|
121 | be searched for a pattern. This is any field in the headers of |
---|
122 | the message that might be present. |
---|
123 | |
---|
124 | The following special fields are also defined: |
---|
125 | .sp |
---|
126 | .in +1i |
---|
127 | .ta +1i |
---|
128 | .ti -1i |
---|
129 | \fIsource\fR the out-of-band sender information |
---|
130 | .ti -1i |
---|
131 | \fIaddr\fR the address that was used to cause delivery to the recipient |
---|
132 | .ti -1i |
---|
133 | \fIdefault\fR this matches \fIonly\fR if the message hasn't been delivered yet |
---|
134 | .ti -1i |
---|
135 | \fI*\fR this always matches |
---|
136 | .in -1i |
---|
137 | |
---|
138 | .ti -.5i |
---|
139 | \fBpattern\fR: |
---|
140 | .br |
---|
141 | The sequence of characters to match in the specified header field. |
---|
142 | Matching is case-insensitive, but does not use regular expressions. |
---|
143 | |
---|
144 | .ti -.5i |
---|
145 | \fBaction\fR: |
---|
146 | .br |
---|
147 | The action to take to deliver the message. When a message is delivered, |
---|
148 | a \*(lqDelivery\-Date:\ date\*(rq header is added which indicates the date |
---|
149 | and time that message was delivered. |
---|
150 | .sp |
---|
151 | .in +1i |
---|
152 | .ta +1i |
---|
153 | .ti -1i |
---|
154 | \fIdestroy\fR |
---|
155 | This action always succeeds. |
---|
156 | |
---|
157 | .ti -1i |
---|
158 | \fIfile\fR, \fImbox\fR, or > |
---|
159 | Append the message to the file named by \fBstring\fR. The message is |
---|
160 | appended to the file in mbox (uucp) format. This is the format used by most |
---|
161 | other mail clients (such as mailx, elm). If the message can be appended to |
---|
162 | the file, then this action succeeds. |
---|
163 | |
---|
164 | .ti -1i |
---|
165 | \fImmdf\fR Identical to \fIfile\fR, but always appends the message using |
---|
166 | the MMDF mailbox format. |
---|
167 | |
---|
168 | .ti -1i |
---|
169 | \fIpipe\fR or | |
---|
170 | Pipe the message as the standard input to the command named by |
---|
171 | \fBstring\fR, using the Bourne shell \fIsh\fR(1) to interpret the string. |
---|
172 | Prior to giving the string to the shell, it is expanded with the following |
---|
173 | built-in variables: |
---|
174 | .sp |
---|
175 | .in +1i |
---|
176 | .ta +1i |
---|
177 | .ti -1i |
---|
178 | $(sender) the out-of-band sender information |
---|
179 | .ti -1i |
---|
180 | $(address) the address that was used to cause delivery to the recipient |
---|
181 | .ti -1i |
---|
182 | $(size) the size of the message in bytes |
---|
183 | .ti -1i |
---|
184 | $(reply\-to) either the \*(lqReply\-To:\*(rq or \*(lqFrom:\*(rq field |
---|
185 | of the message |
---|
186 | .ti -1i |
---|
187 | $(info) the out-of-band information specified |
---|
188 | .in -1i |
---|
189 | |
---|
190 | .ti -1i |
---|
191 | \fIqpipe\fR or <caret> Similar to \fIpipe\fR, but executes the command |
---|
192 | directly, after built-in variable expansion, without assistance from |
---|
193 | the shell. This action can be used to avoid quoting special characters |
---|
194 | which your shell might interpret. |
---|
195 | |
---|
196 | .ti -1i |
---|
197 | \fIfolder\fR or \fI\+\fR Store the message in the nmh folder named |
---|
198 | by \fBstring\fR. Currently his is handled by piping the message to the nmh |
---|
199 | program `rcvstore', although this may change in the future. |
---|
200 | |
---|
201 | .in -1i |
---|
202 | .ti -.5i |
---|
203 | \fBresult\fR: |
---|
204 | .br |
---|
205 | Indicates how the action should be performed: |
---|
206 | |
---|
207 | .in +1i |
---|
208 | .ta +1i |
---|
209 | .ti -1i |
---|
210 | \fIA\fR Perform the action. If the action succeeds, then the message |
---|
211 | is considered delivered. |
---|
212 | |
---|
213 | .ti -1i |
---|
214 | \fIR\fR Perform the action. |
---|
215 | Regardless of the outcome of the action, the message is not considered |
---|
216 | delivered. |
---|
217 | |
---|
218 | .ti -1i |
---|
219 | \fI?\fR Perform the action only if the message has not been delivered. |
---|
220 | If the action succeeds, then the message is considered delivered. |
---|
221 | |
---|
222 | .ti -1i |
---|
223 | \fIN\fR Perform the action only if the message has not been delivered |
---|
224 | and the previous action succeeded. If this action succeeds, then the |
---|
225 | message is considered delivered. |
---|
226 | .sp |
---|
227 | .in -1i |
---|
228 | .in -.5i |
---|
229 | |
---|
230 | The delivery file is always read completely, so that several matches |
---|
231 | can be made and several actions can be taken. |
---|
232 | .fi |
---|
233 | |
---|
234 | .Uh "Security of Delivery Files" |
---|
235 | In order to prevent security problems, the \fI\&.maildelivery\fR |
---|
236 | file must be owned either by the user or by root, and must be |
---|
237 | writable only by the owner. If this is not the case, the file is |
---|
238 | not read. |
---|
239 | |
---|
240 | If the \fI\&.maildelivery\fR file cannot be found, or does not |
---|
241 | perform an action which delivers the message, then \fIslocal\fP |
---|
242 | will check for a global delivery file at %etcdir%/maildelivery. |
---|
243 | This file is read according to the same rules. This file must be |
---|
244 | owned by the root and must be writable only by the root. |
---|
245 | |
---|
246 | If a global delivery file cannot be found or does not perform an |
---|
247 | action which delivers the message, then standard delivery to the |
---|
248 | user's maildrop is performed. |
---|
249 | .fi |
---|
250 | |
---|
251 | .Uh "Example Delivery File" |
---|
252 | To summarize, here's an example delivery file: |
---|
253 | .sp |
---|
254 | .if t .in +.5i |
---|
255 | .nf |
---|
256 | .ta \w'default 'u +\w'mh-workersxx 'uC +\w'destroy 'uC +\w'result 'u |
---|
257 | # |
---|
258 | # .maildelivery file for nmh's slocal |
---|
259 | # |
---|
260 | # Blank lines and lines beginning with a '#' are ignored |
---|
261 | # |
---|
262 | # FIELD PATTERN ACTION RESULT STRING |
---|
263 | # |
---|
264 | |
---|
265 | # File mail with foobar in the \*(lqTo:\*(rq line into file foobar.log |
---|
266 | To foobar file A foobar.log |
---|
267 | |
---|
268 | # Pipe messages from coleman to the program message-archive |
---|
269 | From coleman pipe A /bin/message-archive |
---|
270 | |
---|
271 | # Anything to the \*(lqnmh-workers\*(rq mailing list is put in |
---|
272 | # its own folder, if not filed already |
---|
273 | To nmh-workers folder ? nmh-workers |
---|
274 | |
---|
275 | # Anything with Unix in the subject is put into |
---|
276 | # the file unix-mail |
---|
277 | Subject unix file A unix-mail |
---|
278 | |
---|
279 | # I don't want to read mail from Steve, so destroy it |
---|
280 | From steve destroy A \- |
---|
281 | |
---|
282 | # Put anything not matched yet into mailbox |
---|
283 | default \- file ? mailbox |
---|
284 | |
---|
285 | # always run rcvtty |
---|
286 | * \- pipe R /nmh/lib/rcvtty |
---|
287 | .re |
---|
288 | .fi |
---|
289 | |
---|
290 | .Uh "Sub-process environment" |
---|
291 | When a process is invoked, its environment is: the user/group-ids are |
---|
292 | set to recipient's ids; the working directory is the recipient's home |
---|
293 | directory; the umask is 0077; the process has no /dev/tty; the standard |
---|
294 | input is set to the message; the standard output and diagnostic output are |
---|
295 | set to /dev/null; all other file-descriptors are closed; the environment |
---|
296 | variables \fB$USER\fR, \fB$HOME\fR, \fB$SHELL\fR are set appropriately, |
---|
297 | and no other environment variables exist. |
---|
298 | |
---|
299 | The process is given a certain amount of time to execute. If the process |
---|
300 | does not exit within this limit, the process will be terminated with |
---|
301 | extreme prejudice. The amount of time is calculated as ((size / 60) + |
---|
302 | 300) seconds, where size is the number of bytes in the message (with |
---|
303 | 30 minutes the maximum time allowed). |
---|
304 | |
---|
305 | The exit status of the process is consulted in determining the success |
---|
306 | of the action. An exit status of zero means that the action succeeded. |
---|
307 | Any other exit status (or abnormal termination) means that the action |
---|
308 | failed. |
---|
309 | |
---|
310 | In order to avoid any time limitations, you might implement a process |
---|
311 | that began by \fIforking\fR. The parent would return the appropriate |
---|
312 | value immediately, and the child could continue on, doing whatever it |
---|
313 | wanted for as long as it wanted. This approach is somewhat risky if |
---|
314 | the parent is going to return an exit status of zero. If the parent is |
---|
315 | going to return a non-zero exit status, then this approach can lead to |
---|
316 | quicker delivery into your maildrop. |
---|
317 | .Fi |
---|
318 | ^%etcdir%/mts.conf~^nmh mts configuration file |
---|
319 | ^$HOME/\&.maildelivery~^The file controlling local delivery |
---|
320 | ^%etcdir%/maildelivery~^Rather than the standard file |
---|
321 | ^%mailspool%/$USER~^The default maildrop |
---|
322 | .Sa |
---|
323 | rcvdist(1), rcvpack(1), rcvstore(1), rcvtty(1), mh\-format(5) |
---|
324 | .De |
---|
325 | `\-noverbose' |
---|
326 | .Ds |
---|
327 | `\-nosuppressdup' |
---|
328 | .Ds |
---|
329 | `\-maildelivery \&.maildelivery' |
---|
330 | .Ds |
---|
331 | `\-mailbox %mailspool%/$USER' |
---|
332 | .Ds |
---|
333 | `\-file' defaults to stdin |
---|
334 | .Ds |
---|
335 | `\-user' defaults to the current user |
---|
336 | .Co |
---|
337 | None |
---|
338 | .Hi |
---|
339 | \fISlocal\fP was originally designed to be backward-compatible with |
---|
340 | the \fImaildelivery\fP facility provided by \fIMMDF-II\fP. Thus, the |
---|
341 | \fI\&.maildelivery\fP file syntax is somewhat limited. But \fIslocal\fP |
---|
342 | has been modified and extended, so that is it no longer compatible with |
---|
343 | \fIMMDF-II\fP. |
---|
344 | |
---|
345 | In addition to an exit status of zero, the \fIMMDF\fR values \fIRP_MOK\fR |
---|
346 | (32) and \fIRP_OK\fR (9) mean that the message has been fully delivered. |
---|
347 | Any other non-zero exit status, including abnormal termination, is |
---|
348 | interpreted as the \fIMMDF\fR value \fIRP_MECH\fR (200), which means |
---|
349 | \*(lquse an alternate route\*(rq (deliver the message to the maildrop). |
---|
350 | .Bu |
---|
351 | Only two return codes are meaningful, others should be. |
---|
352 | |
---|
353 | \fISlocal\fP was originally designed to be backwards-compatible with the |
---|
354 | \fImaildelivery\fP functionality provided by \fBMMDF-II\fP. |
---|