1SLOCAL(1)                    [nmh-1.2-20070115cvs]                   SLOCAL(1)
2
3
4

NAME

6       slocal - asynchronously filter and deliver new mail
7

SYNOPSIS

9       /usr/libexec/nmh/slocal [address info sender] [-addr address] [-info
10            data] [-sender sender] [-user username] [-mailbox mbox] [-file
11            file] [-maildelivery deliveryfile] [-verbose | -noverbose] [-sup‐
12            pressdup | -nosuppressdup] [-debug] [-version] [-help]
13

DESCRIPTION

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
18       behalf  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
23       alternate 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  command  line  arguments,  or
30       arguments to the -addr and -sender switches.
31
32       The message is normally read from the standard input.  The -file switch
33       sets the name of the file  from  which  the  message  should  be  read,
34       instead of reading stdin.  This is useful when debugging a “.maildeliv‐
35       ery” file.
36
37       The -user switch tells slocal the name of  the  user  for  whom  it  is
38       delivering  mail.   The  -mailbox  switch  tells slocal the name of the
39       user's maildrop file.
40
41       slocal is able to detect and suppress duplicate  messages.   To  enable
42       this,  use  the  option -suppressdup.  slocal will keep a database con‐
43       taining the Message-ID's of  incoming  messages,  in  order  to  detect
44       duplicates.   Depending on your configuration, this database will be in
45       either ndbm or Berkeley db format.
46
47       The -info switch may be used to pass an arbitrary argument to  sub-pro‐
48       cesses which slocal may invoke on your behalf.
49
50       The  -verbose  switch causes slocal to give information on stdout about
51       its progress.  The -debug switch produces more verbose debugging output
52       on  stderr.   These  flags  are useful when creating and debugging your
53.maildelivery” file, as they  allow  you  to  see  the  decisions  and
54       actions  that  slocal  is taking, as well as check for syntax errors in
55       your “.maildelivery” file.
56
57
58   Message Transfer Agents
59       Most modern MTAs including sendmail, postfix and exim support  a  .for‐
60       ward file for directing incoming mail.  You should include the line
61
62            “| /usr/libexec/nmh/slocal -user username”
63
64       in your .forward file in your home directory.  This will cause your MTA
65       to invoke slocal on your behalf when a message arrives.
66
67
68   The Maildelivery File
69       The “.maildelivery” file  controls  how  slocal  filters  and  delivers
70       incoming  mail.   Each line of this file consists of five fields, sepa‐
71       rated by white-space or comma.  Since double-quotes are honored,  these
72       characters may be included in a single argument by enclosing the entire
73       argument in double-quotes.  A double-quote can be included by preceding
74       it  with  a  backslash.   Lines  beginning with `#' and blank lines are
75       ignored.
76
77       The format of each line in the “.maildelivery” file is:
78
79            header    pattern   action    result    string
80
81       header:
82            The name of a header field (such as To, Cc,  or From) that  is  to
83            be  searched  for  a pattern.  This is any field in the headers of
84            the message that might be present.
85
86            The following special fields are also defined:
87
88            source    the out-of-band sender information
89
90            addr      the address that was  used  to  cause  delivery  to  the
91                      recipient
92
93            default   this  matches  only if the message hasn't been delivered
94                      yet
95
96            *         this always matches
97
98       pattern:
99            The sequence of characters to match in the specified header field.
100            Matching  is  case-insensitive,  but  does not use regular expres‐
101            sions.
102
103       action:
104            The action to take to deliver the  message.   When  a  message  is
105            delivered, a “Delivery-Date: date” header is added which indicates
106            the date and time that message was delivered.
107
108            destroy      This action always succeeds.  file, mbox, or > Append
109                         the message to the file named by string.  The message
110                         is appended to the file in mbox (uucp) format.   This
111                         is  the  format used by most other mail clients (such
112                         as mailx, elm).  If the message can  be  appended  to
113                         the file, then this action succeeds.
114
115            mmdf         Identical  to  file,  but  always appends the message
116                         using the MMDF mailbox format.
117
118            pipe or |    Pipe the message as the standard input to the command
119                         named  by string, using the Bourne shell sh to inter‐
120                         pret the string.  Prior to giving the string  to  the
121                         shell,  it  is  expanded  with the following built-in
122                         variables:
123
124                         $(sender)     the out-of-band sender information
125
126                         $(address)    the address  that  was  used  to  cause
127                                       delivery to the recipient
128
129                         $(size)       the size of the message in bytes
130
131                         $(reply-to)   either the “Reply-To:” or “From:” field
132                                       of the message
133
134                         $(info)       the out-of-band information specified
135
136            qpipe or ^   Similar to pipe, but executes the  command  directly,
137                         after built-in variable expansion, without assistance
138                         from the shell.  This action can  be  used  to  avoid
139                         quoting  special  characters  which  your shell might
140                         interpret.
141
142            folder or +  Store the message in the nmh folder named by  string.
143                         Currently  this  is  handled by piping the message to
144                         the nmh program rcvstore, although this may change in
145                         the future.
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
168   Security of Delivery Files
169       In order to prevent security problems, the “.maildelivery” file must be
170       owned  either  by the user or by root, and must be writable only by the
171       owner.  If this is not the case, the file is not read.
172
173       If the “.maildelivery” file cannot be found, or  does  not  perform  an
174       action  which delivers the message, then slocal will check for a global
175       delivery file at /etc/nmh/maildelivery.  This file is read according to
176       the  same  rules.   This  file  must  be  owned by the root and must be
177       writable only by the root.
178
179       If a global delivery file cannot be found or does not perform an action
180       which  delivers the message, then standard delivery to the user's mail‐
181       drop is performed.
182
183
184   Example Delivery File
185       To summarize, here's an example delivery file:
186
187       #
188       # .maildelivery file for nmh's slocal
189       #
190       # Blank lines and lines beginning with a '#' are ignored
191       #
192       # FIELD   PATTERN   ACTION  RESULT  STRING
193       #
194
195       # File mail with foobar in the “To:” line into file foobar.log
196       To        foobar    file    A       foobar.log
197
198       # Pipe messages from coleman to the program message-archive
199       From      coleman   pipe    A       /bin/message-archive
200
201       # Anything to the “nmh-workers” mailing list is put in
202       # its own folder, if not filed already
203       To        nmh-workers  folder ?     nmh-workers
204
205       # Anything with Unix in the subject is put into
206       # the file unix-mail
207       Subject   unix      file    A       unix-mail
208
209       # I don't want to read mail from Steve, so destroy it
210       From      steve     destroy A       -
211
212       # Put anything not matched yet into mailbox
213       default   -        file    ?       mailbox
214
215       # always run rcvtty
216       *         -        pipe    R       /usr/libexec/nmh/rcvtty
217
218
219   Sub-process environment
220       When a process is invoked, its environment is: the  user/group-ids  are
221       set  to  recipient's ids; the working directory is the recipient's home
222       directory; the umask is 0077; the process has no /dev/tty; the standard
223       input  is set to the message; the standard output and diagnostic output
224       are set to /dev/null; all other file-descriptors are closed; the  envi‐
225       ronment  variables  $USER,  $HOME, $SHELL are set appropriately, and no
226       other environment variables exist.
227
228       The process is given a certain amount  of  time  to  execute.   If  the
229       process does not exit within this limit, the process will be terminated
230       with extreme prejudice.  The amount of time is calculated as  ((size  /
231       60)  +  300)  seconds, where size is the number of bytes in the message
232       (with 30 minutes the maximum time allowed).
233
234       The exit status of the process is consulted in determining the  success
235       of the action.  An exit status of zero means that the action succeeded.
236       Any other exit status (or abnormal termination) means that  the  action
237       failed.
238
239       In  order  to avoid any time limitations, you might implement a process
240       that began by fork()-ing.  The  parent  would  return  the  appropriate
241       value  immediately,  and the child could continue on, doing whatever it
242       wanted for as long as it wanted.  This approach is  somewhat  risky  if
243       the parent is going to return an exit status of zero.  If the parent is
244       going to return a non-zero exit status, then this approach can lead  to
245       quicker delivery into your maildrop.
246
247

FILES

249       /etc/nmh/mts.conf          nmh mts configuration file
250       $HOME/.maildelivery        The file controlling local delivery
251       /etc/nmh/maildelivery      Rather than the standard file
252       /var/mail/$USER            The default maildrop
253
254

SEE ALSO

256       rcvdist(1), rcvpack(1), rcvstore(1), rcvtty(1), mh-format(5)
257
258

DEFAULTS

260       `-noverbose'
261       `-nosuppressdup'
262       `-maildelivery' defaults to $HOME/.maildelivery
263       `-mailbox' deaults to /var/mail/$USER
264       `-file' defaults to stdin
265       `-user' defaults to the current user
266
267

CONTEXT

269       None
270
271

HISTORY

273       Slocal  was  originally  designed  to  be  backward-compatible with the
274       maildelivery facility provided by MMDF-II.  Thus,  the  “.maildelivery
275       file  syntax  is  somewhat  limited.   But slocal has been modified and
276       extended, so that is it no longer compatible with MMDF-II.
277
278       In addition to an exit status of zero, the MMDF values RP_MOK (32)  and
279       RP_OK  (9)  mean  that the message has been fully delivered.  Any other
280       non-zero exit status, including abnormal termination, is interpreted as
281       the  MMDF  value  RP_MECH  (200),  which means “use an alternate route”
282       (deliver the message to the maildrop).
283
284

BUGS

286       Only two return codes are meaningful, others should be.
287
288       Slocal was originally designed  to  be  backwards-compatible  with  the
289       maildelivery functionality provided by MMDF-II.
290
291
292
293MH.6.8                            1 Jul 2003                         SLOCAL(1)
Impressum