SLOCAL(1)
π SLOCAL π
okay bestie, this is slocal from section 1 of the manual β General Commands Manual vibes. it's the nmh mail-filtering icon and she is busy. let's get into it π
β¨ NAME β¨
slocal β asynchronously filter and deliver new mail to nmh
π¦ SYNOPSIS π¦
/usr/libexec/nmh/slocal [-help] [-version] [-addr address] [-info data]
[-sender sender] [-user username] [-mailbox mbox] [-file file]
[-maildelivery deliveryfile] [-verbose | -noverbose] [-suppressdup
| -nosuppressdup] [-debug]
πΈ DESCRIPTION πΈ
okay so slocal is a program designed to let you have your inbound mail processed according to a complex set of selection criteria. you do not normally invoke slocal yourself β instead, slocal gets invoked on your behalf by your system's Message Transfer Agent (such as sendmail) when the message arrives. she's working behind the scenes, main character energy but make it invisible π
the message selection criteria used by slocal is specified in the file .maildelivery in the user's home directory. you can specify an alternate file with the -maildelivery file option. the syntax of this file is specified below π
the message delivery address and message sender are determined from the Message Transfer Agent envelope information, if possible. under sendmail, the sender will obtained from the UUCP From: line, if present. the user may override these values with the -addr and -sender switches.
the message is normally read from the standard input. the -file switch sets the name of the file from which the message should be read, instead of reading stdin. this is useful when debugging a .maildelivery file. π΅οΈ
the -user switch tells slocal the name of the user for whom it is delivering mail. it must exist on the local system. the -mailbox switch tells slocal the name of the user's mail drop file.
slocal is able to detect and suppress duplicate messages. to enable this, use the option -suppressdup. slocal will keep a database containing the Message-ID's of incoming messages, in order to detect duplicates. depending on your configuration, this database will be in either ndbm or Berkeley db format.
the -info switch may be used to pass an arbitrary argument to subprocesses which slocal may invoke on your behalf.
the -verbose switch causes slocal to give information on stdout about its progress. the -debug switch produces more verbose debugging output on stderr. these flags are useful when creating and debugging your .maildelivery file, as they allow you to see the decisions and actions that slocal is taking, as well as check for syntax errors in your .maildelivery file. β¨
π Message Transfer Agents π
most modern MTAs including sendmail, postfix, and exim support a .forward file for directing incoming mail. you should include the line
"| /usr/libexec/nmh/slocal -user username"
in your .forward file in your home directory. this will cause your MTA to invoke slocal on your behalf when a message arrives. slay π«Ά
π¬ The Maildelivery File π¬
the .maildelivery file controls how slocal filters and delivers incoming mail. each line of this file consists of five fields, separated by whitespace or comma. since double-quotes are honored, these characters may be included in a single argument by enclosing the entire argument in double-quotes. a double-quote can be included by preceding it with a backslash. lines beginning with # and blank lines are ignored.
the format of each line in the .maildelivery file is:
header pattern action result string
π header:
the name of a header field (such as To, Cc, or From) that is to be searched for a pattern. this is any field in the headers of the message that might be present.
the following special fields are also defined:
sourceβ the out-of-band sender informationaddrβ the address that was used to cause delivery to the recipientdefaultβ this matches only if the message hasn't been delivered yet*β this always matches
π§ pattern:
the sequence of characters to match in the specified header field. matching is case-insensitive, but does not use regular expressions. (iykyk, no regex here bestie)
π action:
the action to take to deliver the message. when a message is delivered, a Delivery-Date: date header is added which indicates the date and time that message was delivered.
destroyβ this action always succeeds. πfile,mbox, or>β append the message to the file named by string. the message is appended to the file in mbox (uucp) format. this is the format used by most other mail clients (such asmailx,elm). if the message can be appended to the file, then this action succeeds.mmdfβ identical tofile, but always appends the message using the MMDF mailbox format.pipeor|β pipe the message as the standard input to the command named by string, using the Bourne shellshto interpret the string. prior to giving the string to the shell, it is expanded with the following built-in variables:$(sender)β the out-of-band sender information$(address)β the address that was used to cause delivery to the recipient$(size)β the size of the message in bytes$(reply-to)β either theReply-To:orFrom:field of the message$(info)β the out-of-band information specified
qpipeor^β similar topipe, but executes the command directly, after built-in variable expansion, without assistance from the shell. this action can be used to avoid quoting special characters which your shell might interpret.folderor+β store the message in the nmh folder named by string by piping the message to the nmh programrcvstore.
β result:
indicates how the action should be performed:
Aβ perform the action. if the action succeeds, then the message is considered delivered.Rβ perform the action. regardless of the outcome of the action, the message is not considered delivered.?β perform the action only if the message has not been delivered. if the action succeeds, then the message is considered delivered.Nβ perform the action only if the message has not been delivered and the previous action succeeded. if this action succeeds, then the message is considered delivered.
the delivery file is always read completely, so that several matches can be made and several actions can be taken. π
π Security of Delivery Files π
in order to prevent security problems, the .maildelivery file must be owned either by the user or by root, and must be writable only by the owner. if this is not the case, the file is not read. π«
if the .maildelivery file cannot be found, or does not perform an action which delivers the message, then slocal will check for a global delivery file at /etc/nmh/maildelivery. this file is read according to the same rules. this file must be owned by root and must be writable only by root.
if a global delivery file cannot be found or does not perform an action which delivers the message, then standard delivery to the user's mail drop is performed.
π Example Delivery File π
to summarize, here's an example delivery file:
#
# .maildelivery file for nmh's slocal
#
# Blank lines and lines beginning with a '#' are ignored
#
# FIELD PATTERN ACTION RESULT STRING
#
# File mail with foobar in the βTo:β line into file foobar.log
To foobar file A foobar.log
# Pipe messages from coleman to the program message-archive
From coleman pipe A /bin/message-archive
# Anything to the βnmh-workersβ mailing list is put in
# its own folder, if not filed already
To nmh-workers folder ? nmh-workers
# Anything with Unix in the subject is put into
# the file unix-mail
Subject unix file A unix-mail
# I don't want to read mail from Steve, so destroy it
From steve destroy A -
# Put anything not matched yet into mailbox
default - file ? mailbox
# always run rcvtty
* - pipe R /usr/libexec/nmh/rcvtty
π§ Sub-process environment π§
when a process is invoked, its environment is: the user/group-ids are set to recipient's ids; the working directory is the recipient's home directory; the umask is 0077; the process has no /dev/tty; the standard input is set to the message; the standard output and diagnostic output are set to /dev/null; all other file-descriptors are closed; the environment variables $USER, $HOME, $SHELL are set appropriately, and no other environment variables exist.
the process is given a certain amount of time to execute. if the process does not exit within this limit, the process will be terminated with extreme prejudice. the amount of time is calculated as ((size / 60) + 300) seconds, where size is the number of bytes in the message (with 30 minutes the maximum time allowed).
the exit status of the process is consulted in determining the success of the action. an exit status of zero means that the action succeeded. any other exit status (or abnormal termination) means that the action failed.
in order to avoid any time limitations, you might implement a process that began by fork()-ing. the parent would return the appropriate value immediately, and the child could continue on, doing whatever it wanted for as long as it wanted. this approach is somewhat risky if the parent is going to return an exit status of zero. if the parent is going to return a non-zero exit status, then this approach can lead to quicker delivery into your mail drop. π
π FILES π
/etc/nmh/mts.confβ nmh mts configuration file$HOME/.maildeliveryβ the file controlling local delivery/etc/nmh/maildeliveryβ rather than the standard file/var/mail/$USERβ the default mail drop
π SEE ALSO π
rcvdist(1), rcvpack(1), rcvstore(1), rcvtty(1), mh-format(5)
π DEFAULTS π
-noverbose-nosuppressdup-maildeliverydefaults to$HOME/.maildelivery-mailboxdefaults to/var/mail/$USER-filedefaults to stdin-addrdefaults to the current user-userdefaults to the current user
-addr and -user will be set the the user part of the Local-Mailbox profile entry, if set.
π CONTEXT π
None
okay that's part 1 done bestie, keep reading because there's more coming π
β¨ HISTORY β¨
okay so storytime bestie π β slocal was originally designed to be backward-compatible with the maildelivery facility that MMDF-II provided. so the .maildelivery file syntax is kinda... limited? like it's giving "we had to make it work with the old thing" energy π. but slocal has since been modified and extended, so babes, it is no longer compatible with MMDF-II. periodt. that era is over π
.
now here's the part where the exit codes get spicy πΆοΈ β in addition to an exit status of zero, the MMDF values RP_MOK (32) and RP_OK (9) both mean the message has been fully delivered β¨.
any other non-zero exit status, including abnormal termination, gets interpreted as the MMDF value RP_MECH (200) β which means "use an alternate route" (aka deliver the message to the mail drop) πββοΈπ¨.
fr fr, remember this one. the wrong exit code and your mail goes on a lil detour π
π«Ά BUGS π«Ά
- only two return codes are meaningful π the others should be, but they're not. it's giving lazy. it's giving "we'll finish it later." it's giving unfinished business π
- and a lil echo from the history section, because it really do be like that:
slocalwas originally designed to be backwards-compatible with themaildeliveryfunctionality provided by MMDF-II. (yes bestie, this is the same lore, they said it twice, and honestly? relatable π)
and that's the whole page, bestie π you now know slocal from the nmh-1.8 release, dated 2022-03-13 β go forth, filter your mail, and slay π
β¨πΈπ
π¦ where this page comes from
- alpine 3.24: nmh-doc 1.8-r3 Β· BSD-3-Clause
- epel 10: nmh 1.8-3.el10_1 Β· BSD
- epel 9: nmh 1.8-1.el9 Β· BSD
- fedora 43: nmh 1.8-9.fc43 Β· LicenseRef-Callaway-BSD
- fedora 44: nmh 1.8-10.fc44 Β· LicenseRef-Callaway-BSD
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms