1SLOCAL(1) General Commands Manual SLOCAL(1)
2
3
4
6 slocal - asynchronously filter and deliver new mail to nmh
7
9 /usr/libexec/nmh/slocal [-help] [-version] [-addr address] [-info data]
10 [-sender sender] [-user username] [-mailbox mbox] [-file file]
11 [-maildelivery deliveryfile] [-verbose | -noverbose] [-suppressdup
12 | -nosuppressdup] [-debug]
13
15 slocal is a program designed to allow you to have your inbound mail
16 processed according to a complex set of selection criteria. You do not
17 normally invoke slocal yourself, rather slocal is invoked on your be‐
18 half by your system's Message Transfer Agent (such as sendmail) when
19 the message arrives.
20
21 The message selection criteria used by slocal is specified in the file
22 “.maildelivery” in the user's home directory. You can specify an al‐
23 ternate file with the -maildelivery file option. The syntax of this
24 file is specified below.
25
26 The message delivery address and message sender are determined from the
27 Message Transfer Agent envelope information, if possible. Under send‐
28 mail, the sender will obtained from the UUCP “From:” line, if present.
29 The user may override these values with the -addr and -sender switches.
30
31 The message is normally read from the standard input. The -file switch
32 sets the name of the file from which the message should be read, in‐
33 stead of reading stdin. This is useful when debugging a “.maildeliv‐
34 ery” file.
35
36 The -user switch tells slocal the name of the user for whom it is de‐
37 livering mail. It must exist on the local system. The -mailbox switch
38 tells slocal the name of the user's mail drop file.
39
40 slocal is able to detect and suppress duplicate messages. To enable
41 this, use the option -suppressdup. slocal will keep a database con‐
42 taining the Message-ID's of incoming messages, in order to detect du‐
43 plicates. Depending on your configuration, this database will be in
44 either ndbm or Berkeley db format.
45
46 The -info switch may be used to pass an arbitrary argument to sub-pro‐
47 cesses which slocal may invoke on your behalf.
48
49 The -verbose switch causes slocal to give information on stdout about
50 its progress. The -debug switch produces more verbose debugging output
51 on stderr. These flags are useful when creating and debugging your
52 “.maildelivery” file, as they allow you to see the decisions and ac‐
53 tions that slocal is taking, as well as check for syntax errors in your
54 “.maildelivery” file.
55
56 Message Transfer Agents
57 Most modern MTAs including sendmail, postfix, and exim support a .for‐
58 ward file for directing incoming mail. You should include the line
59
60 “| /usr/libexec/nmh/slocal -user username”
61
62 in your .forward file in your home directory. This will cause your MTA
63 to invoke slocal on your behalf when a message arrives.
64
65 The Maildelivery File
66 The “.maildelivery” file controls how slocal filters and delivers in‐
67 coming mail. Each line of this file consists of five fields, separated
68 by whitespace or comma. Since double-quotes are honored, these charac‐
69 ters may be included in a single argument by enclosing the entire argu‐
70 ment in double-quotes. A double-quote can be included by preceding it
71 with a backslash. Lines beginning with `#' and blank lines are ig‐
72 nored.
73
74 The format of each line in the “.maildelivery” file is:
75
76 header pattern action result string
77
78 header:
79 The name of a header field (such as To, Cc, or From) that is to
80 be searched for a pattern. This is any field in the headers of
81 the message that might be present.
82
83 The following special fields are also defined:
84
85 source the out-of-band sender information
86
87 addr the address that was used to cause delivery to the re‐
88 cipient
89
90 default this matches only if the message hasn't been delivered
91 yet
92
93 * this always matches
94
95 pattern:
96 The sequence of characters to match in the specified header field.
97 Matching is case-insensitive, but does not use regular expres‐
98 sions.
99
100 action:
101 The action to take to deliver the message. When a message is de‐
102 livered, a “Delivery-Date: date” header is added which indicates
103 the date and time that message was delivered.
104
105 destroy
106 This action always succeeds.
107
108 file, mbox, or >
109 Append the message to the file named by string. The message
110 is appended to the file in mbox (uucp) format. This is the
111 format used by most other mail clients (such as mailx, elm).
112 If the message can be appended to the file, then this action
113 succeeds.
114
115 mmdf
116 Identical to file, but always appends the message using the
117 MMDF mailbox format.
118
119 pipe or |
120 Pipe the message as the standard input to the command named by
121 string, using the Bourne shell sh to interpret the string.
122 Prior to giving the string to the shell, it is expanded with
123 the following built-in variables:
124
125 $(sender) the out-of-band sender information
126
127 $(address) the address that was used to cause delivery to
128 the recipient
129
130 $(size) the size of the message in bytes
131
132 $(reply-to) either the “Reply-To:” or “From:” field of the
133 message
134
135 $(info) the out-of-band information specified
136
137 qpipe or ^
138 Similar to pipe, but executes the command directly, after
139 built-in variable expansion, without assistance from the
140 shell. This action can be used to avoid quoting special char‐
141 acters which your shell might interpret.
142
143 folder or +
144 Store the message in the nmh folder named by string by piping
145 the message to the nmh program rcvstore.
146
147 result:
148 Indicates how the action should be performed:
149
150 A Perform the action. If the action succeeds, then the message
151 is considered delivered.
152
153 R Perform the action. Regardless of the outcome of the action,
154 the message is not considered delivered.
155
156 ? Perform the action only if the message has not been delivered.
157 If the action succeeds, then the message is considered deliv‐
158 ered.
159
160 N Perform the action only if the message has not been delivered
161 and the previous action succeeded. If this action succeeds,
162 then the message is considered delivered.
163
164 The delivery file is always read completely, so that several
165 matches can be made and several actions can be taken.
166
167 Security of Delivery Files
168 In order to prevent security problems, the “.maildelivery” file must be
169 owned either by the user or by root, and must be writable only by the
170 owner. If this is not the case, the file is not read.
171
172 If the “.maildelivery” file cannot be found, or does not perform an ac‐
173 tion which delivers the message, then slocal will check for a global
174 delivery file at /etc/nmh/maildelivery. This file is read according to
175 the same rules. This file must be owned by root and must be writable
176 only by root.
177
178 If a global delivery file cannot be found or does not perform an action
179 which delivers the message, then standard delivery to the user's mail
180 drop is performed.
181
182 Example Delivery File
183 To summarize, here's an example delivery file:
184
185 #
186 # .maildelivery file for nmh's slocal
187 #
188 # Blank lines and lines beginning with a '#' are ignored
189 #
190 # FIELD PATTERN ACTION RESULT STRING
191 #
192
193 # File mail with foobar in the “To:” line into file foobar.log
194 To foobar file A foobar.log
195
196 # Pipe messages from coleman to the program message-archive
197 From coleman pipe A /bin/message-archive
198
199 # Anything to the “nmh-workers” mailing list is put in
200 # its own folder, if not filed already
201 To nmh-workers folder ? nmh-workers
202
203 # Anything with Unix in the subject is put into
204 # the file unix-mail
205 Subject unix file A unix-mail
206
207 # I don't want to read mail from Steve, so destroy it
208 From steve destroy A -
209
210 # Put anything not matched yet into mailbox
211 default - file ? mailbox
212
213 # always run rcvtty
214 * - pipe R /usr/libexec/nmh/rcvtty
215
216 Sub-process environment
217 When a process is invoked, its environment is: the user/group-ids are
218 set to recipient's ids; the working directory is the recipient's home
219 directory; the umask is 0077; the process has no /dev/tty; the standard
220 input is set to the message; the standard output and diagnostic output
221 are set to /dev/null; all other file-descriptors are closed; the envi‐
222 ronment variables $USER, $HOME, $SHELL are set appropriately, and no
223 other environment variables exist.
224
225 The process is given a certain amount of time to execute. If the
226 process does not exit within this limit, the process will be terminated
227 with extreme prejudice. The amount of time is calculated as ((size /
228 60) + 300) seconds, where size is the number of bytes in the message
229 (with 30 minutes the maximum time allowed).
230
231 The exit status of the process is consulted in determining the success
232 of the action. An exit status of zero means that the action succeeded.
233 Any other exit status (or abnormal termination) means that the action
234 failed.
235
236 In order to avoid any time limitations, you might implement a process
237 that began by fork()-ing. The parent would return the appropriate
238 value immediately, and the child could continue on, doing whatever it
239 wanted for as long as it wanted. This approach is somewhat risky if
240 the parent is going to return an exit status of zero. If the parent is
241 going to return a non-zero exit status, then this approach can lead to
242 quicker delivery into your mail drop.
243
245 /etc/nmh/mts.conf nmh mts configuration file
246 $HOME/.maildelivery The file controlling local delivery
247 /etc/nmh/maildelivery Rather than the standard file
248 /var/mail/$USER The default mail drop
249
251 rcvdist(1), rcvpack(1), rcvstore(1), rcvtty(1), mh-format(5)
252
254 `-noverbose'
255 `-nosuppressdup'
256 `-maildelivery' defaults to $HOME/.maildelivery
257 `-mailbox' defaults to /var/mail/$USER
258 `-file' defaults to stdin
259 `-addr' defaults to the current user
260 `-user' defaults to the current user
261
262 -addr and -user will be set the the user part of the Local-Mailbox pro‐
263 file entry, if set.
264
266 None
267
269 slocal was originally designed to be backward-compatible with the
270 maildelivery facility provided by MMDF-II. Thus, the “.maildelivery”
271 file syntax is somewhat limited. But slocal has been modified and ex‐
272 tended, so that is it no longer compatible with MMDF-II.
273
274 In addition to an exit status of zero, the MMDF values RP_MOK (32) and
275 RP_OK (9) mean that the message has been fully delivered. Any other
276 non-zero exit status, including abnormal termination, is interpreted as
277 the MMDF value RP_MECH (200), which means “use an alternate route” (de‐
278 liver the message to the mail drop).
279
281 Only two return codes are meaningful, others should be.
282
283 slocal was originally designed to be backwards-compatible with the
284 maildelivery functionality provided by MMDF-II.
285
286
287
288nmh-1.8 2022-03-13 SLOCAL(1)