SLOCAL(1mh)

πŸ“¦
version 1.8 Β· 4 versions
, in debian trixie, ubuntu noble, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸŽ€ 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

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 information
  • addr β€” the address that was used to cause delivery to the recipient
  • default β€” 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 as mailx, elm). if the message can be appended to the file, then this action succeeds.
  • mmdf β€” identical to file, but always appends the message using the MMDF mailbox format.
  • pipe or | β€” pipe the message as the standard input to the command named by string, using the Bourne shell sh to 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 the Reply-To: or From: field of the message
    • $(info) β€” the out-of-band information specified
  • qpipe or ^ β€” similar to pipe, 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. ✨
  • folder or + β€” store the message in the nmh folder named by string by piping the message to the nmh program rcvstore. πŸ“

🎯 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) and RP_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 😭)
  • slocal was originally designed to be backwards-compatible with the maildelivery functionality 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