SLOCAL(1mh)
π SLOCAL π
bestie. sit down. hydrate. we're doing slocal, and it's from the 1mh corner of the manual, and it's a whole vibe.
β¨ NAME β¨
slocal β asynchronously filter and deliver new mail to nmh. π
π¦ SYNOPSIS π¦
/usr/lib/mh/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. it's giving personal assistant for your inbox, no cap. π«Ά
and here's the thing β you do not normally invoke slocal yourself. nope. instead, slocal is invoked on your behalf by your system's Message Transfer Agent (such as sendmail) when the message arrives. it's the main character working behind the scenes while you sleep. π
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. (yes, "will obtained" β that's literally what the page says, we don't fix it, we respect it π). 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/lib/mh/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. it's literally one line, bestie, and your mail starts filtering itself. iconic. π
πΈ 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. so don't come at it with your fancy regex, it's not that kind of girl. π
π¬ 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. (yes, it just. deletes. it. and it succeeds at it. slay π)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. like, it does not stop at the first hit, bestie. it reads the whole thing. every single time. π«‘
π« HISTORY π«
ok so storytime bestie π β slocal was originally designed to be backward-compatible with the maildelivery facility that MMDF-II provides. that's the lore β¨.
which means the .maildelivery file syntax is, ngl, somewhat limited π. it's giving vintage. it's giving legacy. it is what it is.
but β and this is the glow-up β slocal has been modified and extended since then, so it is no longer compatible with MMDF-II. periodt π
. the old ways are the old ways.
now, exit statuses, because we love an exit status π«Ά:
- besides an exit status of zero, the MMDF values
RP_MOK (32)andRP_OK (9)mean the message has been fully delivered β . - literally any other non-zero exit status β including abnormal termination π β is interpreted as the MMDF value
RP_MECH (200), which means "use an alternate route" (aka deliver the message to the mail drop) π.
π BUGS π
- only two return codes are meaningful. others should be. (yes bestie, the manpage is out here roasting itself, we love the self-awareness π)
slocalwas originally designed to be backwards-compatible with themaildeliveryfunctionality of MMDF-II. (this is the same lore from HISTORY, it's just showing up again like an ex that won't leave the group chat π« )
and that's the whole page, my love π this was SLOCAL(1mh) from nmh-1.8, dated 2022-03-13 β screenshot it, bookmark it, tattoo it, whatever serves you bestie π go forth and filter your mail like the main character you are πβ¨
π¦ where this page comes from
- debian trixie: nmh 1.8-3
- ubuntu noble: nmh 1.8-1build4
- ubuntu questing: nmh 1.8-3
- ubuntu resolute: nmh 1.8-4
- ubuntu stonking: nmh 1.8-4build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms