S-NAIL(1)
💌 S-NAIL(1) — the send-and-receive Internet mail queen 👑
✨ NAME ✨
S-nail [v14.9.25] — send and receive Internet mail 💖
✨ SYNOPSIS ✨
Ok bestie, here’s the summoning circle ✨:
s-nail [-DdEFinv~#] [-: spec] [-A account] [:-a attachment:]
[:-b bcc-addr:] [:-C "field: body":] [:-c cc-addr:]
[-M type | -m file | -q file | -t] [-r from-addr]
[:-S var[=value]:] [-s subject] [:-T "field: addr":] [:-X cmd:]
[:-Y cmd:] [-.] :to-addr: [-- :mta-option:]
s-nail [-DdEeHiNnRv~#] [-: spec] [-A account] [:-C "field: body":]
[-L spec] [-r from-addr] [:-S var[=value]:] [-u user] [:-X cmd:]
[:-Y cmd:] [-- :mta-option:]
s-nail [-DdEeHiNnRv~#] [-: spec] [-A account] [:-C "field: body":] -f
[-L spec] [-r from-addr] [:-S var[=value]:] [:-X cmd:] [:-Y cmd:]
[file] [-- :mta-option:]
s-nail -h | --help
s-nail -V | --version
✨ DESCRIPTION ✨
Note: S-nail (S-nail) will see major changes in v15.0 (circa 2022). Some backward incompatibilities cannot be avoided. “COMMANDS” change to “Shell-style argument quoting”, and shell metacharacters will become (more) meaningful. Some commands accept new syntax today via wysh (“Command modifiers”). Behaviour is flagged [v15-compat] and [no v15-compat], setting v15-compat (“INTERNAL VARIABLES”) will choose new behaviour when applicable; giving it a value makes wysh an implied default. [Obsolete] flags what will vanish.
Warning! v15-compat (with value) will be a default in v14.10.0!
Okay so S-nail is literally your simple and friendly little environment for sending and receiving mail. It is intended to provide the functionality of the POSIX mailx(1) command, but it is MIME capable and optionally offers extensions for line editing, S/MIME, SMTP and POP3, among others. S-nail divides incoming mail into its constituent messages and allows the user to deal with them in any order. It offers many “COMMANDS” and “INTERNAL VARIABLES” for manipulating messages and sending mail. It provides the user simple editing capabilities to ease the composition of outgoing messages, and increasingly powerful and reliable non-interactive scripting capabilities. Iconic behavior, no cap. 💅
✨ Options ✨
-: spec,--resource-files=..— bestie, this one controls the loading of (as viasource) “Resource files”.specis parsed case-insensitively: the letterscorresponds to the system wides-nail.rc, anduis the user's personal file~/.mailrc. The (original) system wide resource is also compiled-in, accessible viax. The letters-and/disable usage of resource files. Order matters, default issu. This option overrides-n. ✨-A name,--account=..— Activate user accountnameafter program startup is complete (resource files loaded, only-Xcommands are to be executed), and switch to its “primary system mailbox” (most likely the inbox). If activation fails the program exits if used non-interactively, or if any oferrexitorposixare set. Account glow-up, but make it careful. 🫶-a file[=input-charset[#output-charset]],--attach=..— (Send mode) Attachfile. For (Compose mode) opportunities refer to~@and~^.fileis subject to tilde expansion (see “Filename transformations” andfolder); if it is not accessible but contains a=character, anything before the last=will be used as the filename, anything thereafter as a character set specification, as shown.
If only an input character set is specified, the input side is fixed, and no character set conversion will be applied; an empty or the special string hyphen-minus - is taken for ttycharset (the default). If an output character set has also been specified the desired conversion is performed immediately, not considering file type and content, except for an empty string or hyphen-minus -, which select the default conversion algorithm (see “Character sets”): no immediate conversion is performed, file and its contents will be MIME-classified (“HTML mail and MIME attachments, The mime.types files”) first — only the latter mode is available unless features includes ,+iconv,. Attachment drama, but make it charset-aware. 🎀
-B— ([Obsolete]: S-nail will always use line-buffered output, to gain line-buffered input even in batch mode enable batch mode via-#.)-b addr,--bcc=..— (Send mode) Send a blind carbon copy to recipientaddr. The option may be used multiple times. Also see the section “On sending mail, and non-interactive mode”. Secret lil copy, bestie. 🙈-C "field: body",--custom-header=..— Create a custom header which persists for an entire session. A custom header consists of the field name followed by a colon:and the field contentbody, for example-C "Blah: Neminem laede; imo omnes, quantum potes, juva". Standard header field names cannot be overwritten by custom headers. Runtime adjustable custom headers are available via the variablecustomhdr, and in (Compose mode)~^, one of the “COMMAND ESCAPES”, as well asdigmsgare the most flexible and powerful options to manage message headers. This option may be used multiple times. Custom header era. 👑-c addr,--cc=..— (Send mode) Just like-b, except it places the argument in the list of carbon copies. Carbon copy, but visible. ✨-D,--disconnected— [Option] Startup with disconnected set. Offline main character energy. 🦋-d,--debug— Enter a debug-only sandbox mode by setting the internal variabledebug; the same can be achieved via-S debugorset debug. Also see-v. Sandbox mode, let’s investigate. 🔍-E,--discard-empty-messages— (Send mode) setskipemptybodyand thus discard messages with an empty message part body, successfully. No empty-body nonsense allowed. 💀-e,--check-and-exit— Just check if mail is present (in the system inbox or the one specified via-f): if yes, return an exit status of zero, a non-zero value otherwise. To restrict the set of mails to consider in this evaluation a message specification can be added with the option-L. Quickrun: does not open an interactive session. Just peeking, then leaving. 👀-F— (Send mode) Save the message to send in a file named after the local part of the first recipient's address (instead of inrecord). Filename from the first recipient, periodt. 💅-f,--file— Read in the contents of the user's “secondary mailbox”MBOX(or the specifiedfile) for processing; when S-nail is quit, it writes undeleted messages back to this file (but be aware of theholdoption). The optionalfileargument will undergo some special “Filename transformations” (as viafolder). Note thatfileis not an argument to the flag-f, but is instead taken from the command line after option processing has been completed. In order to use a file that starts with a hyphen-minus, prefix with a relative path, as in./-hyphenbox.mbox. Secondary mailbox, but make it transformative. 🌸-H,--header-summary— Display a summary of headers for the given folder (depending on-u,inboxorMAIL, or as specified via-f), then exit. A configurable summary view is available via the option-L. This mode does not honourshowlast. Quickrun: does not open an interactive session. Header summary, then dip. ✨-h,--help— Show a brief usage summary; use--long-helpfor a list long options. Help, bestie! 🫶-i— setignoreto ignore tty interrupt signals. Ignore the interrupt, slay. 💅-L spec,--search=..— Display a summary of headers of all messages that match the givenspecin the folder found by the same algorithm used by-H, then exit. See the section “Specifying messages” for the format ofspec. This mode does not honourshowlast.
If the -e option has been given in addition no header summary is produced, but S-nail will instead indicate via its exit status whether spec matched any messages (0) or not (1); note that any verbose output is suppressed in this mode and must instead be enabled explicitly (see -v). Quickrun: does not open an interactive session. Search mode has receipts. 🔎
-M type— (Send mode) Will flag standard input with the MIMEContent-Type:set to the given knowntype(“HTML mail and MIME attachments, The mime.types files”) and use it as the main message body. [v15 behaviour may differ] Using this option will bypass processing ofmessage-inject-headandmessage-inject-tail. Also see-q,-m,-t. MIME type on stdin, main body behavior. 🔥-m file— (Send mode) MIME classify the specifiedfileand use it as the main message body. [v15 behaviour may differ] Using this option will bypass processing ofmessage-inject-headandmessage-inject-tail. Also see-q,-M,-t. Classify the file, then make it the body. 💖-N,--no-header-summary— inhibit the initial display of message headers when reading mail or editing a mailbox folder by callingunsetfor the internal variableheader. No header summary, just vibes. 🙈-n— Standard flag that inhibits reading the system wides-nail.rcupon startup. The option-:allows more control over the startup sequence; also see “Resource files”. Skip the system rc, bestie. 🎀-q file,--quote-file=..— (Send mode) Initialize the message body with the contents offile, which may be standard input-only in non-interactive context. Also see-M,-m,-t. Quote file initialization, but only non-interactively for-. 🦋-R,--read-only— Any mailbox folder akafolderopened will be in read-only mode. Do not touch, just read. 💀-r from-addr,--from-address=..— The RFC 5321 reverse-path used for relaying and delegating messages to its destination(s), for example to report delivery errors, is normally derived from the address which appears in thefromheader (or, if that contains multiple addresses, insender). A file-based aka local executablemta(Mail-Transfer-Agent), however, instead uses the local identity of the initiating user. Reverse-path lore, fr fr. 🌈
Okay so back to this one — when you use this command line option, the given single addressee from-addr gets assigned to the internal variable from, but on top of that the command line option -f from-addr will be passed to a file-based mta whenever a message is sent. And if from-addr happens to include a user name, then the address components get separated and the name part is passed to the file-based mta individually via -F name. And even though it's not a recipient, the shquote expandaddr flag is supported. 🫶
If you pass an empty string as from-addr, then the content of the variable from gets evaluated — or, if from holds multiple addresses, then sender gets evaluated instead — and that's what gets used for this purpose whenever the file-based mta is contacted. By default, and "without -r" is what that means, neither the -f nor the -F command line options are used when contacting a file-based MTA, unless this automatic deduction gets enforced by setting the internal variable r-option-implicit. ✨
Remarks: a whole lot of default installations and sites will not allow overriding the local user identity like this unless either the MTA has been configured accordingly, or the user is a member of a group with special privileges. And passing an invalid address will cause an error. No cap. 💀
-S var[=value],--set=..— set variable and optionally assign value, if that's supported. (Or, with a prefix string'no', like it's documented in “INTERNAL VARIABLES”, unset it.) [v15 behaviour may differ] the entire expression is evaluated as if it had been specified within dollar-single-quotes (peep “Shell-style argument quoting”) if the internal variablev15-compatis set. If the operation fails, the program will exit if any oferrexitorposixare set. Settings established via-Scannot be changed from within “Resource files” or from an account switch initiated by-A. They become mutable again before commands registered via-Xare executed. 💅-s subject,--subject=..— (Send mode) Specify the subject of the message to be sent. Newline (NL) and carriage-return (CR) bytes are invalid and will be normalized to space (SP) characters.-T "field: addr",--target=..— (Send mode) Add addr to the list of receivers targeted by field. For now the only ones supported are'bcc','cc','fcc', and'to'. Field and body (address) are separated by a colon':'and optionally blank (space, tabulator) characters. Theshquoteexpandaddrflag is supported. addr is parsed like a message header address line, as if it would be part of a template message fed in via-t, and the same modifier suffix is supported. This option may be used multiple times. 🎀-t,--template— (Send mode) The text message given (on standard input) is expected to contain one or multiple plain text message headers, separated from the message body by an empty line. [v15 behaviour may differ] Readily prepared MIME mail messages cannot be passed. Headers can span multiple consecutive lines if follow lines start with any amount of whitespace. A line starting with the number sign'#'in the first column is ignored. Message recipients can be given via the message headers'To:','Cc:','Bcc:'(the'?single'modifier enforces treatment as a single addressee, for example'To?single: exa, <m@ple>') or'Fcc:'; they will be added to any recipients specified on the command line, and are likewise subject toexpandaddrvalidity checks. If a message subject is specified via'Subject:'then it will be used in favour of one given on the command line. 💖
More optional headers are 'Reply-To:' (possibly overriding reply-to), 'Sender:' (sender), 'From:' (from and / or option -r). 'Message-ID:', 'In-Reply-To:', 'References:' and 'Mail-Followup-To:', by default created automatically dependent on message context, will be used if specified (a special address massage will however still occur for the latter). Any other custom header field (also see -C, customhdr and ~^) is passed through entirely unchanged, and in conjunction with the options -~ or -# it is possible to embed “COMMAND ESCAPES”. Also see -M, -m, -q.
-u user,--inbox-of=..— Initially read the “primary system mailbox” of user, appropriate privileges presumed; effectively identical to'-f %user'.-V,--version— Show S-nails version and exit. The command version will also show the list of features:'$ s-nail -:/ -Xversion -Xx'. 👑-v,--verbose— sets the internal variableverboseto enable logging of informational context messages. (Increases level of verbosity when used multiple times.) Also see-d. 🌸-X cmd,--startup-cmd=..— Add the given (or multiple, for a multiline argument) cmd to a list of commands to be executed before normal operation starts. The commands will be evaluated as a unit, just as viasource. Correlates with-#anderrexit.-Y cmd,--cmd=..— Add the given (or multiple, for a multiline argument) cmd to a list of commands to be executed after normal operation has started. The commands will be evaluated successively in the given order, and as if given on the program's standard input — before interactive prompting begins in interactive mode, after standard input has been consumed otherwise.-~,--enable-cmd-escapes— Enable “COMMAND ESCAPES” in (Compose mode) even in non-interactive use cases. This can for example be used to automatically format the composed message text before sending the message: 🦋
$ ( echo 'line one. Word. Word2.';\
echo '~| /usr/bin/fmt -tuw66' ) |\
LC_ALL=C s-nail -d~:/ -Sttycharset=utf-8 bob@exam.ple
-#,--batch-mode— Enables batch mode: standard input is made line buffered, the complete set of (interactive) commands is available, processing of “COMMAND ESCAPES” is enabled in “Compose mode”, and diverse “INTERNAL VARIABLES” are adjusted for batch necessities, exactly as if done via-S:emptystart,noerrexit,noheader,noposix,quiet,sendwait,typescript-modeas well asMAIL,MBOXandinbox(the latter three to/dev/null). Also, the values ofCOLUMNSandLINESare looked up, and acted upon. The following prepares an email message in a batched dry run: 💜
$ for name in bob alice@exam.ple lisa@exam.ple; do
printf 'mail %s\n~s ubject\nText\n~.\n' "${name}"
done |
LC_ALL=C s-nail -#:x -Smta=test \
-X'alias bob bob@exam.ple'
-.,--end-options— This flag forces termination of option processing in order to prevent “option injection” (attacks). It also forcefully puts S-nail into send mode, see “On sending mail, and non-interactive mode”. 🫶
If the setting of expandargv allows their recognition, all mta-option arguments given at the end of the command line after a '--' separator will be passed through to a file-based mta (Mail-Transfer-Agent) and persist for the entire session. expandargv constraints do not apply to the content of mta-arguments. Command line receiver address handling supports the 'shquote' constraint of expandaddr; for more please see “On sending mail, and non-interactive mode”.
$ s-nail -#:/ -X 'addrcodec enc Hey, ho <silver@go>' -Xx
🌈 A starter 🌈
S-nail is a direct descendant of BSD Mail, itself a successor to the Research Unix mail which “was there from the start” according to “HISTORY”. So it literally represents the user side of the Unix mail system, whereas the system side (Mail-Transfer-Agent, MTA) was traditionally taken by sendmail(8) (and most MTAs provide a binary of this name for compatibility reasons). If the [Option]al SMTP mta is included in the features of S-nail then the system side is not a mandatory precondition for mail delivery. ✨
S-nail strives for compliance with the POSIX mailx(1) standard, but posix, one of the “INTERNAL VARIABLES”, or its “ENVIRONMENT”al equivalent POSIXLY_CORRECT, needs to be set to adjust behaviour to be almost on par. Almost, because there is one important difference: POSIX “Shell-style argument quoting” is ([v15 behaviour may differ] increasingly) used instead of the “Old-style argument quoting” that the standard documents, which is believed to be a feature. The builtin as well as the (default) global s-nail.rc “Resource files” already bend the standard imposed settings a bit. 💅
For example, hold and keepsave are set in order to suppress the automatic moving of messages to the “secondary mailbox” MBOX that would otherwise occur (see “Message states”), and keep to not remove empty system MBOX mailbox files (or all empty such files in posix mode) to avoid mangling of file permissions when files eventually get recreated. 🎀
To enter interactive mode even if the initial mailbox is empty emptystart is set, editheaders to allow editing of headers as well as fullnames to not strip down addresses in “Compose mode”, and quote to include the message that is being responded to when replying, which is indented by an indentprefix that also deviates from standard imposed settings. mime-counter-evidence is fully enabled, too. It sets followup-to-honour and reply-to-honour to comply with reply address desires. 💖
Credentials and other settings are easily addressable by grouping them via account. The file mode creation mask can be managed with umask. Files and shell pipe output can be sourced for evaluation, also during startup from within the “Resource files”. Informational context can be available by setting verbose or debug (as via -v, -d). 🌸
On sending mail, and non-interactive mode 💌
Okay bestie, so to send a message to one or more people — using a local or built-in mta (that's Mail-Transfer-Agent, the thing that actually delivers the generated mail message) — you invoke S-nail with arguments that are the names of the people you're sending to. And the command line options -b and -c? They're literally right there to add (blind) carbon copy receivers. Slay. ✨
# Via test MTA
$ echo Hello, world | s-nail -:/ -Smta=test -s test $LOGNAME
# Via sendmail(1) MTA
$ </dev/null s-nail -:x -s test $LOGNAME
# Debug dry-run mode:
$ </dev/null LC_ALL=C s-nail -d -:/ \
-Sttycharset=utf8 -Sfullnames \
-b bcc@exam.ple -c cc@exam.ple -. \
'(Lovely) Bob <bob@exam.ple>' eric@exam.ple
# With SMTP (no real sending due to -d debug dry-run)
$ LC_ALL=C s-nail -d -:/ -Sv15-compat -Sttycharset=utf8 \
-S mta=smtps://mylogin@exam.ple:465 -Ssmtp-auth=none \
-S from=scriptreply@exam.ple \
-a /etc/mail.rc --end-options \
eric@exam.ple < /tmp/letter.txt
Email addresses and plain user names are subject to alternates filtering, and names only are first expanded through alias and mta-aliases. An address in angle brackets consisting only of a valid local user ‘<name>’ will be converted to a fully qualified address if either hostname is not set, or set to a non-empty value; if set to the empty value the conversion is left up to the mta. By setting expandaddr you get fine-grained control of recipient address types other than user names and network addresses. Recipients are classified as follows, no cap:
- Any name that starts with a vertical bar
‘|’character specifies a command pipe — the command string following the‘|’is executed and the message is sent to its standard input. - Likewise, any name that consists only of hyphen-minus
‘-’or starts with the character solidus‘/’or the character sequence dot solidus‘./’is treated as a file, regardless of the remaining content. - Any other name which contains a commercial at
‘@’character is a network address. - Any other name which starts with a plus sign
‘+’character is a mailbox name. - Any other name which contains a solidus
‘/’character but no exclamation mark‘!’or percent sign‘%’character before is also a mailbox name. - What remains is treated as a network address.
This classification can be avoided by using a ‘Fcc:’ header, see “Compose mode”.
$ echo bla | s-nail -Sexpandaddr -s test ./mbox.mbox
$ echo bla | s-nail -Sexpandaddr -s test '|cat >> ./mbox.mbox'
$ echo safe | LC_ALL=C \
s-nail -:/ -Smta=test -Sv15-compat -Sttycharset=utf8 \
--set mime-force-sendout --set fullnames \
-S expandaddr=fail,-all,+addr,failinvaddr -s test \
--end-options 'Imagine John <cold@turk.ey>'
Before messages are sent they undergo editing in “Compose mode”. But many settings are static and can be set more generally. The envelope sender address, for example, is defined by from; explicitly defining an originating hostname may be desirable, especially with the built-in SMTP Mail-Transfer-Agent mta. “Character sets” for outgoing message and MIME part content are configurable via sendcharsets, whereas input data is assumed to be in ttycharset. Message data will be passed over the wire in a mime-encoding, and MIME parts aka attachments need a mimetype, usually taken out of “The mime.types files”. Saving copies of sent messages in a record mailbox may be desirable — as for most mailbox folder targets “Filename transformations” will be performed.
For the purpose of arranging a complete environment of settings that can be switched to with a single command or command line option there are accounts. Alternatively a flat configuration could be possible, making use of so-called variable chains which automatically pick ‘USER@HOST’ or ‘HOST’ context-dependent variants some variables support: for example addressing ‘Folder pop3://yaa@exam.ple’ would find pop3-no-apop-yaa@exam.ple, pop3-no-apop-exam.ple and pop3-no-apop in order. For more please see “On URL syntax and credential lookup” and “INTERNAL VARIABLES”.
To avoid environmental noise scripts should create a script-local environment, ideally with the command line options -: to disable configuration files in conjunction with repetitions of -S to specify variables:
$ env LC_ALL=C s-nail -:/ \
-Sv15-compat \
-Sttycharset=utf-8 -Smime-force-sendout \
-Sexpandaddr=fail,-all,failinvaddr \
-S mta=smtps://mylogin@exam.ple:465 -Ssmtp-auth=login \
-S from=scriptreply@exam.ple \
-s 'Subject to go' -a attachment_file \
-Sfullnames -. \
'Recipient 1 <rec1@exam.ple>' rec2@exam.ple \
< content_file
As shown, scripts producing messages can “fake” a locale environment — the above specifies the all-compatible 7-bit clean LC_ALL “C”, but will nonetheless take and send UTF-8 in the message text by using ttycharset. If character set conversion is compiled in (features includes the term ‘,+iconv,’) invalid (according to ttycharset) character input data would normally cause errors; setting mime-force-sendout will instead, as a last resort, classify the input as binary data, and therefore allow message creation to be successful. (Such content can then be inspected either by installing a pipe-TYPE/SUBTYPE handler for ‘application/octet-stream’, or possibly automatically through mime-counter-evidence).
In interactive mode, introduced soon, messages can be sent by calling the mail command with a list of recipient addresses:
$ s-nail -:/ -Squiet -Semptystart -Sfullnames -Smta=test
"/var/spool/mail/user": 0 messages
? mail "Recipient 1 <rec1@exam.ple>", rec2@exam.ple
...
? # Will do the right thing (tm)
? m rec1@exam.ple rec2@exam.ple
Compose mode 💅
If standard input is a terminal rather than the message to be sent, the user is expected to type in the message contents. In compose mode, lines beginning with the character ‘~’ (in fact the value of escape) are special — these are so-called “COMMAND ESCAPES” which can be used to read in files, process shell commands, add and edit attachments and more. For example ~v or ~e will start the VISUAL text EDITOR, respectively, to revise the message in its current state; ~h allows editing of the most important message headers; with the potent ~^ custom headers can be created, for example (more specifically than with -C and customhdr). [Option]ally ~? gives an overview of most other available command escapes.
To create file-carbon-copies the special recipient header ‘Fcc:’ may be used as often as desired, for example via ~^. Its entire value (or body in standard terms) is interpreted as a folder target, after having been subject to “Filename transformations”: this is the only way to create a file-carbon-copy without introducing an ambiguity regarding the interpretation of the address; file names with leading vertical bars or commercial ats can be used. Like all other recipients ‘Fcc:’ is subject to the checks of expandaddr. Any local file and pipe command addressee honours the setting of mbox-fcc-and-pcc.
Once finished with editing the command escape ~. (see there) will call hooks, insert automatic injections and receivers, leave compose mode and send the message once it is completed. Aborting letter composition is possible with either of ~x or ~q, the latter of which will save the message in the file denoted by DEAD unless nosave is set. And unless ignoreeof is set the effect of ~. can also be achieved by typing end-of-transmission (EOT) via ‘control-D’ (‘^D’) at the beginning of an empty line, and ~q is always reachable by typing end-of-text (ETX) twice via ‘control-C’ (‘^C’).
The compose mode hooks on-compose-enter, on-compose-splice, on-compose-leave and on-compose-cleanup may be set to defined macros and provide reliable and increasingly powerful mechanisms to perform automated message adjustments dependent on message context, for example addition of message signatures (message-inject-head, message-inject-tail) or creation of additional receiver lists (also by setting autocc, autobcc). To achieve that the command digmsg may be used in order to query and adjust status of message(s). The splice hook can also make use of “COMMAND ESCAPES”. ([v15 behaviour may differ] The compose mode hooks work for forward, mail, reply and variants; resend and Resend only provide the hooks on-resend-enter and on-resend-cleanup, which are pretty restricted due to the nature of the operation.)
On reading mail, and more on interactive mode 📬
When invoked without addressees S-nail enters interactive mode in which mails may be read. When used like that the user's system inbox (for more on mailbox types please see the command folder) is read in and a one line header of each message therein is displayed if the variable header is set. The visual style of this summary of headers can be adjusted through the variable headline and the possible sorting criterion via autosort. Scrolling through screenfuls of headers can be performed with the command z. If the initially opened mailbox is empty S-nail will instead exit immediately (after displaying a message) unless the variable emptystart is set.
At the prompt the command list will give a listing of all available commands and help will [Option]ally give a summary of some common ones. If the [Option]al documentation strings are available (see features) one can type ‘help X’ (or ‘?X’) and see the actual expansion of ‘X’ and what its purpose is, i.e., commands can be abbreviated (note that POSIX defines some abbreviations, so that the alphabetical order of commands does not necessarily relate to the abbreviations; it is however possible to define overwrites with commandalias). These commands can also produce a more verbose output.
Messages are given numbers (starting at 1) which uniquely identify messages; the current message — the “dot” — will either be the first new message, or the first unread message, or the first message of the mailbox; the internal variable showlast will instead cause usage of the last message for this purpose. The command headers will display a screenful of header summaries containing the “dot”, whereas from will display only the summaries of the given messages, defaulting to the “dot”.
Like, message content? That's the command type (cute short alias t, and also print) 💅. Here's the tea: the variable crt decides whether and when S-nail will hand off to your configured PAGER for the display, instead of just yeeting the text straight onto your terminal screen. That's literally the only difference from the command more, which always uses the PAGER, no questions asked. Meanwhile the command top is the lowkey overachiever — it only shows you the first toplines lines of a message (and it might even compress them too, if topsqueeze is set 🙈).
Want your message-reading experience to be, like, actually good? Try setting and tuning mime-counter-evidence ✨ and also go read the "HTML mail and MIME attachments" section, bestie.
By default the current message (aka the "dot") is what gets displayed, but just like with sooo many other commands you can hand it a fancy message specification (peep "Specifying messages" for the deets). For example:
t:u— displays all unread messages 👀t.— displays the "dot"t 1 5— types messages 1 and 5t 1-5— types messages 1 through 5t-— displays the previous messaget+— displays the next message
Periodt. And the command search (which is just a more substantial alias for from) will show you a header summary of the given message specification list instead of their actual content — so if you wanna hunt for subjects, you do this:
? from '@Some subject to search for'
In the default setup, all header fields of a message get typed out. But bb, fields can be white- or blacklisted for a whole variety of applications using the command headerpick — like if you wanna restrict what shows up for type to a very restricted little set: headerpick type retain from to cc subject. And if you wanna see all the header fields of a message no matter what ignore or retain lists are currently active? Use the commands Type and Top (capital letters, she's fancy 👑). Show will show you the raw message content. Heads up though: historically the global s-nail.rc doesn't just adjust the list of displayed headers, it also sets crt. Also [v15 behaviour may differ] — A yet somewhat restricted — reliable scriptable message inspection is available via digmsg 🌸.
Depending on your configuration, a line editor (check the "On terminal control and line editor" section) is out here trying to make your whole experience with the many "COMMANDS" a bit nicer 🎀. When you're reading the system inbox, or when -f (or folder) specified a mailbox explicitly prefixed with the special %: modifier (which propagates it to a "primary system mailbox"), then messages that have been read (see "Message states") will be automatically moved to a "secondary mailbox" — your MBOX file — when the mailbox is left, whether that's by changing the active mailbox or by quitting S-nail. Lowkey magic ✨. This automatic moving from a system- or primary- to the secondary mailbox is not performed when the variable hold is set, jsyk.
Messages can also be explicitly moved to other mailboxes, whereas copy keeps the original message around. And write can be used to write out the data content of specific parts of messages 💌.
So after you've examined a message, you can reply with r — that goes to the sender and all recipients (who will also be placed in To: unless recipients-in-cc is set), or you can Reply with a big R which goes exclusively to the sender(s). To comply with the receiver's desired reply address, the "quadoption"s followup-to-honour and reply-to-honour should usually be set. The commands Lreply and Lfollowup know how to apply a special addressee massage — see "Mailing lists" for that whole situation 💆. Depending on the presence and value of quote, the message being replied to will be included in a quoted form. And forwarding a message will let you edit the new message: the original message will be contained in the message body, adjusted according to headerpick.
It's also possible to resend or Resend messages: the former will add a series of Resent- headers, whereas the latter will not 🫶. Different from newly created messages, editing is not possible and no copy will be saved even with record — unless the additional variable record-resent is set. And when sending, replying or forwarding messages, comments and full names will be stripped from recipient addresses unless the internal variable fullnames is set. No cap.
Of course messages can be deleted with d 💀 and they can spring back into existence via undelete — or when the S-nail session is ended via the exit or xit commands to perform a quick program termation. But if you wanna end a mail processing session regularly and perform a full program exit, you may issue the command quit. It will, among others, move read messages to the "secondary mailbox" MBOX as necessary, discard deleted messages in the current mailbox, and update the [Option]al (see features) line editor history-file 📜. Oh and btw, whenever the main event loop is about to look out for the next input line, it will trigger the hook on-main-loop-tick. She's always watching ⏰.
🌈 HTML mail and MIME attachments 🌈
HTML-only messages are becoming more and more common, and so many messages come bundled with a whole bouquet of MIME (Multipurpose Internet Mail Extensions) parts and attachments 💐. To get a notion of MIME types there's a built-in default set, onto which the content of "The mime.types files" will be added (as configured and allowed by mimetypes-load-control). Types can also become registered and listed with the command mimetype 🎀. To improve interaction with the faulty MIME part declarations of real life, mime-counter-evidence will allow verification of the given assertion, and the possible provision of an alternative, better MIME type 👑. Note that plain text parts will always be preferred in multipart/alternative MIME messages unless mime-alternative-favour-rich is set.
OK so, a simple HTML-to-text filter for displaying HTML messages is [Option]ally supported (indicated by ,+filter-html-tagsoup, in features), but MIME types other than plain text cannot be handled directly, sorry babe 😭. To deal with specific non-text MIME types or file extensions, programs need to be registered which either prepare (re-)integrable plain text versions of their input (a mode which is called copiousoutput), or display the content externally, for example in a graphical window — that latter type is only considered by and for the command mimeview 🖼️.
To install a handler program for a MIME type, an according pipe-TYPE/SUBTYPE variable needs to be set; to define a handler for a file extension, pipe-EXTENSION can be used — these handlers take precedence ✨. [Option]ally mail user agent configuration is supported (see "The Mailcap files"), and it will be queried for display or quote handlers after the former ones. And type-markers registered via mimetype are the last possible source for information on how to handle a MIME type.
For example, to display HTML messages integrated via the text browsers lynx(1) or elinks(1), register a MathML MIME type and enable its plain text display, and to open PDF attachments in an external PDF viewer, asynchronously and with some other magic attached:
? if "$features" !% ,+filter-html-tagsoup,
? #set pipe-text/html='?* elinks -force-html -dump 1'
? set pipe-text/html='?* lynx -stdin -dump -force_html'
? # Display HTML as plain text instead
? #set pipe-text/html=?t
? endif
? mimetype ?t application/mathml+xml mathml
? wysh set pipe-application/pdf='?&=? \
trap "rm -f \"${MAILX_FILENAME_TEMPORARY}\"" EXIT;\
trap "trap \"\" INT QUIT TERM; exit 1" INT QUIT TERM;\
mupdf "${MAILX_FILENAME_TEMPORARY}"'
? define showhtml {
? \localopts yes
? \set mime-alternative-favour-rich pipe-text/html=?h?
? \type "$@"
? }
? \commandalias html \\call showhtml
💌 Mailing lists 💌
Known or subscribed-to mailing lists may be flagged in the summary of headers (headline format character %L) 👀, and they'll gain special treatment when sending mails: the variable followup-to-honour will ensure that a Mail-Followup-To: header is honoured when a message is being replied to (reply, followup, Lreply, Lfollowup), and followup-to controls creation of this header when creating mails, if the necessary user setup (from, sender) is available; then, it may also be created automatically, for example when list-replying via Lreply or Lfollowup, when followup or reply is used and the messages' Mail-Followup-To: is honoured etc. Iconic behaviour honestly ✨.
The commands mlist and mlsubscribe manage S-nail's notion of which addresses are mailing lists. With the [Option]al regular expression support, any address which contains any of the magic regular expression characters (^[*+?|$; see re_format(7) or regex(7), dependent on the host system) will be compiled and used as one, possibly matching many addresses 🌈. It is not possible to escape the "magic" — in order to match special characters as-is, bracket expressions must be used, for example search @subject@'[[]open bracket'. Iykyk.
? set followup-to followup-to-honour=ask-yes \
reply-to-honour=ask-yes
? mlist a1@b1.c1 a2@b2.c2 '.*@lists\.c3$'
? mlsubscribe a4@b4.c4 exact@lists.c3
Known and subscribed lists differ in that, for the latter, the user's address is not part of a generated Mail-Followup-To: 💅. There are exceptions though, for example if multiple lists are addressed and not all of them have the subscription attribute. When replying to a message, its list address (List-Post: header) is automatically and temporarily treated like a known mlist 👑; depending on the variable reply-to-honour, an existing Reply-To: is used instead (if it's a single address on the same domain as List-Post:) in order to accept a list administrator's wish that is supposed to have been manifested like that.
And for convenience and compatibility with mail programs that do not honour the non-standard M-F-T, an automatic user entry in the carbon-copy Cc: address list of generated messages can be created by setting followup-to-add-cc. This entry will be added whenever the user will be placed in the Mail-Followup-To: list, and is not a regular addressee already. Meanwhile reply-to-swap-in tries to deal with the address rewriting that many mailing-lists nowadays perform to work around DKIM / DMARC etc. standard imposed problems. It's giving damage control 🫠.
🔐 Signed and encrypted messages with S/MIME 🔐
[Option] S/MIME provides two central mechanisms: message signing and message encryption ✨. A signed message contains some data in addition to the regular text. That data can be used to verify that the message has been sent using a valid certificate, that the sender address matches the one in the certificate, and that the message text has not been altered 🔥. Signing a message does not change its regular text; it can be read regardless of whether the recipient's software is able to handle S/MIME. So it's thus usually possible to sign all outgoing messages if so desired. Slay 💖.
Okay so picture this: signing is like a lil wax seal that says "yes bestie, this really came from me" — but the text is still fully readable by anyone. Encryption, in contrast, makes the message text invisible for literally everyone except the people who hold the secret decryption key. ✨ And to encrypt a message, you have to know the specific recipient's public encryption key. Which means… you can't just yeet encrypted mail at someone unless you've already snagged their key from previous communication or from public key directories. 🙈
And here's the iconic little chain-of-logic: signing is performed with private keys, while encryption is performed with public keys — so messages should always be signed before being encrypted. That's the order, no skipping. 💅
🎀 The certification authority (CA) situation 🎀
A central concept to S/MIME is that of the certification authority (CA). A CA is a trusted institution that issues certificates. And for each of these certificates, it can be verified that it really originates from the CA — provided that the CA's own certificate is previously known. 🦋
A set of CA certificates is usually delivered and installed together with the cryptographical library that is used on the local system. Sooo therefore, reasonable security for S/MIME on the Internet is provided if the source that provides that library installation is trusted. It is also possible to use a specific pool of trusted certificates! If that's the vibe you want, then smime-ca-no-defaults should be set to avoid using the default certificate pool, and smime-ca-file and/or smime-ca-dir should be pointed to a trusted pool of certificates.
Heads up bestie: a certificate cannot be more secure than the method its CA certificate has been retrieved with. No cap. 🔥
This trusted pool of certificates is what the command verify uses to make sure the given S/MIME messages can actually be trusted. And if they can be? Then verified sender certificates that were embedded in signed messages can be saved locally with the command certsave, and used by S-nail to encrypt further communication with these senders: 🫶
? certsave FILENAME
? set smime-encrypt-USER@HOST=FILENAME \
smime-cipher-USER@HOST=AES256
Now, to sign outgoing messages — so receivers can verify where those messages came from — you need a personal S/MIME certificate. Fr fr. S-nail supports password-protected personal certificates (and keys), see smime-sign-cert. The section "On URL syntax and credential lookup" gives an overview of the possible sources of user credentials, and "S/MIME step by step" shows examplarily how a private S/MIME certificate can be obtained. 👑
In general, if such a private key plus certificate "pair" is available, all that needs to be done is to set some variables:
? set smime-sign-cert=ME@exam.ple.paired \
smime-sign-digest=SHA512 \
smime-sign from=myname@my.host
Variables of interest for S/MIME in general are smime-ca-dir, smime-ca-file, smime-ca-flags, smime-ca-no-defaults, smime-crl-dir, smime-crl-file. 🌸
For S/MIME signing of interest are smime-sign, smime-sign-cert, smime-sign-include-certs and smime-sign-digest. ✨
Additional variables of interest for S/MIME en- and decryption: smime-cipher and smime-encrypt-USER@HOST. 💖
Variables of secondary interest may be content-description-smime-message and content-description-smime-signature.
And S/MIME is available if ‘,+smime,’ is included in features. 💅
[v15 behaviour may differ] Note that neither S/MIME signing nor encryption applies to message subjects or other header fields yet. So they may not contain sensitive information for encrypted messages, and cannot be trusted even if the message content has been verified. 😭 When sending signed messages, it is recommended to repeat any important header information in the message text.
🌈 On URL syntax and credential lookup 🌈
For accessing protocol-specific resources, Uniform Resource Locators (URL, RFC 3986) have become omnipresent. Here they are expected in a "normalized" variant — not used in data exchange, but only meant as a compact, easy-to-use way of defining and representing information in a well-known notation. As such they do not conform to any real standard. 🤷♀️
Optional parts are placed in brackets ‘[]’, optional either because there also exist other ways to define the information, or because the part is protocol specific. ‘/path’ for example is used by the [Option]al Maildir folder type and the IMAP protocol, but not by POP3.
If ‘USER’ and ‘PASSWORD’ are included in an URL server specification, URL percent encoded (RFC 3986) forms are needed, generable with urlcodec. 🎀
PROTOCOL://[USER[:PASSWORD]@]server[:port][/path]
Often "INTERNAL VARIABLES" exist in multiple versions, called "variable chains" in this document: the plain ‘variable’ as well as ‘variable-HOST’ and ‘variable-USER@HOST’.
- If a port was specified, ‘
HOST’ really means ‘server:port’, not ‘server’. 📌 - And this ‘
USER’ is never in URL percent encoded form.
For example? Whether the hypothetical ‘smtp://wings%3Aof@a.dove’ including user and password was used, or whether it was ‘smtp://a.dove’ and it came from a different source — to lookup the chain tls-config-pairs first ‘tls-config-pairs-wings:of@a.dove’ is looked up, then ‘tls-config-pairs-a.dove’, before finally looking up the plain variable. Order matters, bestie. 🦋
🧚 The credential-collecting logic (as follows) 🧚
- A user is always required. If no ‘
USER’ has been given in the URL, the variablesuser-HOSTanduserare looked up. Afterwards, when enforced by the [Option]al variablesnetrc-lookup-HOSTornetrc-lookup, "The .netrc file" of the user will be searched for a ‘HOST’ specific entry which provides a ‘login’ name: only unambiguous entries are used (one possible matching entry for ‘HOST’).
If there is still no ‘USER’ then the verified LOGNAME, known to be a valid user on the current host, is used. 💁♀️
- Authentication: unless otherwise noted the chain
PROTOCOL-auth-USER@HOST,PROTOCOL-auth-HOST,PROTOCOL-authis checked, falling back to a protocol-specific default as necessary. - If no ‘
PASSWORD’ has been given in the URL, then if the ‘USER’ has been found through the [Option]alnetrc-lookup, that may have also provided the password. Otherwise the chainpassword-USER@HOST,password-HOST,passwordis looked up. 🔑
Thereafter the (now complete) [Option]al chain netrc-lookup-USER@HOST, netrc-lookup-HOST, netrc-lookup is checked; if set, the netrc cache is searched for a password only (multiple user accounts for a single machine may exist as well as a fallback entry without user but with a password).
If at that point there is still no password available, but the (protocols') chosen authentication type requires a password, then in interactive mode the user will be prompted on the terminal. 🫶
Note: S/MIME verification works relative to the values found in the ‘From:’ (or ‘Sender:’) header field(s), which means the values ofsmime-sign,smime-sign-cert,smime-sign-include-certsandsmime-sign-digestwill not be looked up using the ‘USER’ and ‘HOST’ chains from above, but instead use the corresponding values from the message that is being worked on. If no address matches we assume and use the setting offrom.
In unusual cases multiple and different ‘USER’ and ‘HOST’ combinations may therefore be involved — on the other hand, those unusual cases become possible. 😌 The usual case is as short as:
set mta=smtp://USER:PASS@HOST smtp-use-starttls \
smime-sign smime-sign-cert=+smime.pair \
from=myname@my.host
The section "EXAMPLES" contains complete example configurations. 📚
🔒 Encrypted network communication 🔒
[Option] SSL (Secure Sockets Layer) aka its successor TLS (Transport Layer Security) are protocols which aid in securing communication by providing a safely initiated and encrypted network connection. 🌈
A central concept of TLS are certificates: as part of each network connection setup, a (set of) certificates will be exchanged through which the identity of the network peer can be cryptographically verified. If possible, the TLS/SNI (ServerNameIndication) extension will be enabled to allow servers fine-grained control over the certificates being used. A locally installed pool of trusted certificates will then be inspected, and verification will succeed if it contains a(n in)direct signer of the presented certificate(s). ✨
The local pool of trusted so-called CA (Certification Authority) certificates is usually delivered with and used along the TLS library. A custom pool of trusted certificates can be selected by pointing tls-ca-file and/or (with special preparation) tls-ca-dir to the desired location; setting tls-ca-no-defaults in addition will avoid additional inspection of the default pool.
A certificate cannot be more secure than the method its CA certificate has been retrieved with. 🫠
For inspection or other purposes, the certificate of a server (as seen when connecting to it) can be fetched with the command tls (port can usually be the protocol name, too, and tls-verify is taken into account here): 🔍
$ s-nail -vX 'tls certchain SERVER-URL[:PORT]; x'
A local pool of CA certificates is not strictly necessary, however — server certificates can also be verified via their fingerprint. 👆 For this, a message digest will be calculated and compared against the variable chain tls-fingerprint, and verification will succeed if the fingerprint matches. The message digest (algorithm) can be configured via the variable chain tls-fingerprint-digest; tls can again be used:
$ s-nail -X 'wysh set verbose; tls fingerprint SERVER-URL[:PORT]; x'
It depends on the used protocol whether encrypted communication is possible, and which configuration steps have to be taken to enable it. Some protocols, like POP3S, are implicitly encrypted; others, like POP3, can upgrade a plain text connection if so requested. 🦋
For example, to use the ‘STLS’ that POP3 offers, (a member of) the variable (chain) pop3-use-starttls needs to be set — with convenience via shortcut:
shortcut encpop1 pop3s://pop1.exam.ple
shortcut encpop2 pop3://pop2.exam.ple
set pop3-use-starttls-pop2.exam.ple
set mta=smtps://smtp.exam.ple:465
set mta=smtp://smtp.exam.ple smtp-use-starttls
Ok so normally that's literally all there is to do?? Like, TLS libraries are out here trying to provide safe defaults, bestie, they got you 💖 But there's a whole drawer of knobs to adjust settings anyway.
- Certificate verification settings get fine-tuned via
tls-ca-flags✨ - The TLS configuration basics are accessible via
tls-config-pairs— for example to control protocol versions or cipher lists 🌸
Back in the day there were hints on how to restrict the set of protocols to the highly secure ones, but ngl as of the time of this writing the list of protocols or ciphers may need to become relaxed in order to be able to connect to some servers 🫠 The following example lets you connect to a “Lion” that uses OpenSSL 0.9.8za from June 2014 (go peep “INTERNAL VARIABLES” for more on variable chains):
wysh set tls-config-pairs-lion@exam.ple='MinProtocol=TLSv1.1,\
CipherString=TLSv1.2:!aNULL:!eNULL:\
ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:\
DHE-RSA-AES256-SHA:@STRENGTH'
When you're creating a custom cipher list, the OpenSSL program ciphers(1) is the thing to refer to 📖 Variables of interest for TLS in general are tls-ca-dir, tls-ca-file, tls-ca-flags, tls-ca-no-defaults, tls-config-file, tls-config-module, tls-config-pairs, tls-crl-dir, tls-crl-file, tls-rand-file as well as tls-verify. Also see tls-features 👀 TLS is available if +tls is included in features.
🌈 Character sets 🌈
[Option] Your locale environment gets detected by looking at the LC_ALL environment variable 🕵️ The internal variable ttycharset will be set to the detected terminal character set accordingly, and will thus show up in the output of commands like set and varshow 👑 This character set will be targeted when trying to display data, and user input data is expected to be in this character set too. No surprises, periodt.
When creating messages their character input data is classified. 7-bit clean text data and attachments will be classified as charset-7bit ✨ 8-bit data will [Option]ally be converted into members of sendcharsets until a character set conversion succeeds. charset-8bit is the implied default last member of this list 🎀 If no 8-bit character set is capable to represent input data, no message will be sent 😭 and its text will optionally be saved in DEAD. If that is not acceptable — for example in script environments — mime-force-sendout can be set to force sending of non-convertible data as application/octet-stream classified binary content instead: like this receivers still have the option to inspect message content (for example via mime-counter-evidence) 💅 If the [Option]al character set conversion is not available (features misses ,+iconv,), ttycharset is the only supported character set for non 7-bit clean data, and it is simply assumed it can be used to exchange 8-bit messages.
ttycharset may also be given an explicit value to send mail in a completely “faked” locale environment 🧚 which can be used to generate and send for example 8-bit UTF-8 input data in a pure 7-bit US-ASCII LC_ALL=C environment (an example of this can be found in the section “On sending mail, and non-interactive mode”). But word to the wise: due to lack of programming interfaces, reading mail will not really work as expected in a faked environment — whereas ttycharset might be addressable, any output will be made safely printable, as via vexpr makeprint, according to the actual locale environment, which is not affected by ttycharset 💀
Classifying 7-bit clean data as charset-7bit is a problem if the input character set (ttycharset) is a multibyte character set that is itself 7-bit clean 😬 For example, the Japanese character set ISO-2022-JP is, but it's capable to encode the rich set of Japanese Kanji, Hiragana and Katakana characters: in order to notify receivers of this character set the mail message must be MIME encoded so that the character set ISO-2022-JP can be advertised, otherwise an invalid email message would result! 🚨 To achieve this, the variable charset-7bit can be set to ISO-2022-JP. (Today a better approach regarding email is the usage of UTF-8, which uses 8-bit bytes for non-US-ASCII data.) 🌈
When replying to a message and the variable reply-in-same-charset is set, the character set of the message being replied to is tried first as a target character set (still being a subject of charsetalias filtering, however) 💖 Another opportunity is sendcharsets-else-ttycharset to reflect the user's locale environment automatically — it will treat ttycharset as an implied member of (an unset) sendcharsets ✨
[Option] When reading messages, their text data is converted into ttycharset as necessary in order to display them on the user's terminal 👩💻 Unprintable characters and invalid byte sequences are detected and replaced by substitution characters. Character set mappings for source character sets can be established with charsetalias, which may be handy to work around faulty or incomplete character set catalogues (one could for example add a missing LATIN1 to ISO-8859-1 mapping), or to enforce treatment of one character set as another one (“interpret LATIN1 as CP1252”). Also see charset-unknown-8bit to deal with another hairy aspect of message interpretation 🙈
In general, if a message saying “cannot convert from a to b” appears 😭 either some characters are not appropriate for the currently selected (terminal) character set, or the needed conversion is not supported by the system. In the first case, it is necessary to set an appropriate LC_CTYPE locale and/or the variable ttycharset. The best results are usually achieved when running in a UTF-8 locale on a UTF-8 capable terminal, in which case the full Unicode spectrum of characters is available 👑 In this setup characters from various countries can be displayed, while it is still possible to use more simple character sets for sending to retain maximum compatibility with older mail clients. Iconic behaviour honestly.
OTOH the POSIX standard defines a locale-independent 7-bit “portable character set” that should be used when overall portability is an issue 📚 the even more restricted subset named “portable filename character set” consists of A-Z, a-z, 0-9, period ., underscore _ and hyphen-minus -.
💌 Message states 💌
S-nail differentiates in between several message states; the current state will be reflected in the summary of headers if the attrlist of the configured headline allows, and “Specifying messages” dependent on their state is possible 👀 When operating on the system inbox, or in any other “primary system mailbox”, special actions, like the automatic moving of messages to the “secondary mailbox” MBOX, may be applied when the mailbox is left (also implicitly by program termination, unless the command exit was used) — however, because this may be irritating to users which are used to “more modern” mail-user-agents, the provided global s-nail.rc template sets the internal hold and keepsave variables in order to suppress this behaviour 🫶
'new'— Message has neither been viewed nor moved to any other state. Such messages are retained even in the “primary system mailbox”.'unread'— Message has neither been viewed nor moved to any other state, but the message was present already when the mailbox has been opened last: Such messages are retained even in the “primary system mailbox”.'read'— The message has been processed by one of the following commands:~f,~m,~F,~M,copy,mbox,next,pipe,Print,print,top,Type,type,undelete. The commandsdpanddtwill always try to automatically “step” and type the “next” logical message, and may thus mark multiple messages as read, thedeletecommand will do so if the internal variableautoprintis set. Except when theexitcommand is used, messages that are in a “primary system mailbox” and are in'read'state when the mailbox is left will be saved in the “secondary mailbox”MBOXunless the internal variableholdit set.'deleted'— The message has been processed by one of the following commands:delete,dp,dt. Onlyundeletecan be used to access such messages.'preserved'— The message has been processed by apreservecommand and it will be retained in its current location.'saved'— The message has been processed by one of the following commands:saveorwrite. Unless when theexitcommand is used, messages that are in a “primary system mailbox” and are in'saved'state when the mailbox is left will be deleted; they will be saved in the “secondary mailbox”MBOXwhen the internal variablekeepsaveis set.
In addition to these message states, flags which otherwise have no technical meaning in the mail system except allowing special ways of addressing them when “Specifying messages” can be set on messages 🌸 These flags are saved with messages and are thus persistent, and are portable between a set of widely used MUAs. Fancy, right?
answered— Mark messages as having been answered.draft— Mark messages as being a draft.flag— Mark messages which need special attention.
🔍 Specifying messages 🔍
[Only new quoting rules] COMMANDS which take “Message list arguments”, such as search, type, copy, and delete, can perform actions on a number of messages at once 💪 Specifying invalid messages, or using illegal syntax, will cause errors to be reported through the “INTERNAL VARIABLES” !, ^ERR and companions, as well as the command exit status ? 😤
For example, delete 1 2 deletes the messages 1 and 2, whereas delete 1-5 will delete the messages 1 through 5. In sorted or threaded mode (see the sort command), delete 1-5 will delete the messages that are located between (and including) messages 1 through 5 in the sorted/threaded order, as shown in the headers summary 👑
Errors can for example be ^ERR-BADMSG when requesting an invalid message, ^ERR-NOMSG if no applicable message can be found, ^ERR-CANCELED for missing informational data (mostly thread-related). ^ERR-INVAL for invalid syntax as well as ^ERR-IO for input/output errors can happen 💀 The following special message names exist:
.— The current message, the so-called “dot”.;— The message that was previously the current message; needs to be quoted.,— The parent message of the current message, that is the message with theMessage-IDgiven in theIn-Reply-To:field or the last entry of theReferences:field of the current message.-— the previous undeleted message 💌 or, if you're running theundeletecommand, the previous deleted message. And in sorted orthreaded mode? It's the previous such message in the according order, bestie.+— the next undeleted message, or the next deleted one if you're onundelete. Sorted orthreaded mode: next such message in the according order ✨^— the first undeleted message, or the first deleted message for theundeletecommand. Sorted/threaded mode: the first such message in the according order 🥇$— the last message; in sorted orthreaded mode, the last such message in the according order. Bestie it needs to be quoted 🫠&x— inthreaded sort mode this grabs the message addressed with x — where x is literally any other message specification — plus every message from the thread that begins at it 👑 Otherwise it's identical to x. Leave x out and you get the thread that begins with the current message 🧵*— all messages. Every single one. The whole roster 💅`— every message that was included in the “Message list arguments” of the previous command; needs to be quoted. Lowkey the most convenient way to read all your new mail is to select it withfrom :n(see below) and then read it in order with the default command — next — just by typing`over and over 🎀 For this to workshowlastmust be set 🌸x-y— an inclusive range of message numbers. Selectors you're allowed to use as endpoints include any of.;-+^$📬address— a case-insensitive “any substring matches” search against theFrom:header, and it'll match addresses (too) even whenshownameis set (and POSIX says “any address as shown in a header summary shall be matchable in this form”) 📮 However, if theallnetvariable is set, only the local part of the address gets evaluated for the comparison — not ignoring case — and the setting ofshownameis completely ignored 🙈 For finer control and match boundaries, use the@search expression instead./string— all messages that contain string in the subject field (case ignored according to locale). Also peep thesearchheadersvariable. If string is empty, the string from the previous specification of that type gets used again 🔁[@name-list]@expr— all messages that contain the given case-insensitive search expression 💖 If the [Option]al regular expression support is available,exprwill be interpreted as (an extended) one whenever any of the “magic regular expression characters” shows up ✨ Miss out the optional@name-listpart and the search is restricted to the subject field body — but otherwisename-listspecifies a comma-separated list of header fields to search, like for example
'@to,from,cc@Someone i ought to know'
So to search for a string that itself includes a @ (commercial at) character, the name-list is effectively non-optional, but it may be given as the empty string 👀 Also, specifying an empty search expression effectively tests for existence of the given header fields. Some special header fields may be abbreviated: f, t, c, b and s will match From, To, Cc, Bcc and Subject, respectively, and case-insensitively 🎯 [Option]ally, and just like expr, name-list will be interpreted as (an extended) regular expression if any of the “magic regular expression characters” is seen.
The special names header or < can be used to search in (all of) the header(s) of the message, and the special names body or > and text or = will perform full text searches — whereas the former searches only the body, the latter also searches the message header ([v15 behaviour may differ] this mode yet brute force searches over the entire decoded content of messages, including administrativa strings) 🔍
This specification performs full text comparison, but even with regular expression support it is almost impossible to write a search expression that safely matches only a specific address domain 😭 To request that the body content of the header is treated as a list of addresses, and to strip those down to the plain email address which the search expression is to be matched against, prefix the effective name-list with a tilde ~:
'@~f,c@@a\.safe\.domain\.match$'
:c— all messages of state or with matching conditionc, wherecis one or multiple of the following colon modifiers 🍓a— answered messages (cf. the variablemarkanswered).d— “deleted” messages (for theundeleteandfromcommands only).f— flagged messages.L— messages with receivers that matchmlsubscribedaddresses.l— messages with receivers that matchmlistedaddresses.n— “new” messages.o— Old messages (any not in state “read” or “new”).r— “read” messages.S— [Option] messages with unsure spam classification (see “Handling spam”).s— [Option] messages classified as spam.t— messages marked as draft.u— “unread” messages.
[Option] IMAP-style SEARCH expressions may also be used, bestie 💅 These consist of keywords and criterions, and because “Message list arguments” are split into tokens according to “Shell-style argument quoting” it is necessary to quote the entire IMAP search expression to make sure it stays a single token 👑 This addressing mode is available with all types of mailbox folders; S-nail will perform the search locally as necessary. Strings must be enclosed by double quotation marks " in their entirety if they contain whitespace or parentheses; within the quotes, only reverse solidus \ is recognized as an escape character 🫶 All string searches are case-insensitive. When the description indicates that the “envelope” representation of an address field is used, that means the search string is checked against both a list constructed as
'("name" "source" "local-part" "domain-part")'
for each address, and the addresses without real names from the respective header field. These search expressions can be nested using parentheses — see below for examples 🌈
(criterion)— all messages that satisfy the given criterion.(criterion1 criterion2 ... criterionN)— all messages that satisfy all of the given criteria.(or criterion1 criterion2)— all messages that satisfy either criterion1 or criterion2, or both. To connect more than two criteria usingorspecifications you have to nest them with additional parentheses, as with(or a (or b c))— because(or a b c)really means((a or b) and c)💀 For a simpleoroperation of independent criteria on the lowest nesting level, it's possible to get similar effects by using three separate criteria, as with(a) (b) (c).(not criterion)— all messages that do not satisfy criterion.(bcc "string")— all messages that contain string in the envelope representation of theBcc:field.(cc "string")— all messages that contain string in the envelope representation of theCc:field.(from "string")— all messages that contain string in the envelope representation of theFrom:field.(subject "string")— all messages that contain string in theSubject:field.(to "string")— all messages that contain string in the envelope representation of theTo:field.(header name "string")— all messages that contain string in the specifiedName:field.(body "string")— all messages that contain string in their body.(text "string")— all messages that contain string in their header or body.(larger size)— all messages that are larger than size (in bytes).(smaller size)— all messages that are smaller than size (in bytes).(before date)— all messages that were received before date, which must be in the formd[d]-mon-yyyy, whereddenotes the day of the month as one or two digits,monis the name of the month — one ofJan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec— andyyyyis the year as four digits, for example28-Dec-2012📅(on date)— all messages that were received on the specified date.(since date)— all messages that were received since the specified date.(sentbefore date)— all messages that were sent on the specified date.(senton date)— all messages that were sent on the specified date.(sentsince date)— all messages that were sent since the specified date.()— the same criterion as for the previous search. This specification cannot be used as part of another criterion ⚠️ If the previous command line contained more than one independent criterion, then the last of those criteria is used.
🎀 On terminal control and line editor 🎀
[Option] Terminal control through one of the standard Unix libraries, Termcap Access Library (libtermcap, -ltermcap) or Terminal Information Library (libterminfo, -lterminfo), may be available 👀 For the TERMinal defined in the environment, interactive usage aspects — for example “Coloured display” 🌈 — and insight of cursor and function keys for the Mailx-Line-Editor (MLE), will be enhanced or enabled ✨ Library interaction can be disabled on a per-invocation basis via termcap-disable, whereas the internal variable termcap is always used as a preferred source of terminal capabilities 💅 (For a usage example see the “FAQ” entry “Not "defunctional", but the editor key does not work”.)
[Option] The built-in Mailx-Line-Editor (the MLE, she's that girl 💅) should work in all environments that comply to the ISO C standard ISO/IEC 9899/AMD1:1995 ("ISO C90, Amendment 1"), and it'll support wide glyphs if possible — the functionality needed for that had been removed from ISO C 😭, but it was included in X/Open Portability Guide Issue 4 ("XPG4"). Wanna keep a line editor outta your interactive mode entirely? Set line-editor-disable and she's gone. And especially if the [Option]al terminal control support is missing, setting entries in termcap will help shall the MLE misbehave — see there for more 👀. Also: the MLE can support a little bit of colour 🎀.
[Option] If the history feature is available, then input from line editor prompts gets saved in a history list that you can search in and expand from 🔥. You can prevent that saving by prefixing your input with any amount of whitespace (sneaky but legal ✨). Aspects of history — like allowed content, maximum size, and whether history shall be saved persistently — can be configured with the internal variables history-file, history-gabby, history-gabby-persist and history-size. There's also a macro hook, on-history-addition, for when you want finer control over what actually enters history 🫶.
The MLE supports a set of editing and control commands. By default (as) many (as possible) of these get assigned to a set of single-letter control codes, which should work on any terminal (and can be generated by holding the "control" key while pressing the key of desire, for example control-D). If the [Option]al bind command is available, then the MLE commands can also be accessed freely by assigning the command name — the one shown in parenthesis in the list below — to any desired key-sequence, and the MLE will instead and also use bind to establish its built-in key bindings (more of them if the [Option]al terminal control is available), an action which can then be suppressed completely by setting line-editor-no-defaults 🙈. "Shell-style argument quoting" notation is used in the following:
\cA— Go to the start of the line (mle-go-home).\cB— Move the cursor backward one character (mle-go-bwd).\cC—raise(3)SIGINT(mle-raise-int).\cD— Forward delete the character under the cursor; quits S-nail if used on the empty line unless the internal variableignoreeofis set (mle-del-fwd).\cE— Go to the end of the line (mle-go-end).\cF— Move the cursor forward one character (mle-go-fwd).\cG— Cancel current operation, full reset. If there's an active history search or tabulator expansion, then this command will first reset that, reverting to the former line content; thus a second reset is needed for a full reset in this case (mle-reset).\cH— Backspace: backward delete one character (mle-del-bwd).\cI— [Only new quoting rules] Horizontal tabulator: try to expand the word before the cursor, supporting the usual "Filename transformations" (mle-complete; this is affected bymle-quote-rndtripandline-editor-cpl-word-breaks).\cJ— Newline: commit the current line (mle-commit).\cK— Cut all characters from the cursor to the end of the line (mle-snarf-end).\cL— Repaint the line (mle-repaint).\cN—[Option]Go to the next history entry (mle-hist-fwd).\cO— ([Option]ally context-dependent) Invokes the commanddt.\cP—[Option]Go to the previous history entry (mle-hist-bwd).\cQ— Toggle roundtrip mode shell quotes, where produced, on and off (mle-quote-rndtrip). This setting is temporary, and will be forgotten once the command line is committed; also seeshcodec.\cR—[Option]Complete the current line from (the remaining) older history entries (mle-hist-srch-bwd).\cS—[Option]Complete the current line from (the remaining) newer history entries (mle-hist-srch-fwd).\cT— Paste the snarf buffer (mle-paste).\cU— The same as\cAfollowed by\cK(mle-snarf-line).\cV— Prompts for a Unicode character (hexadecimal number without prefix, seevexpr) to be inserted (mle-prompt-char). Note that this command needs to be assigned to a single-letter control code in order to become recognized and executed during input of a key-sequence (only three single-letter control codes can be used for that shortcut purpose 😭); this control code is then special-treated and thus cannot be part of any other sequence (because it will trigger themle-prompt-charfunction immediately).\cW— Cut the characters from the one preceding the cursor to the preceding word boundary (mle-snarf-word-bwd).\cX— Move the cursor forward one word boundary (mle-go-word-fwd).\cY— Move the cursor backward one word boundary (mle-go-word-bwd).\cZ—raise(3)SIGTSTP(mle-raise-tstp).\c[— Escape: reset a possibly used multibyte character input state machine and[Option]ally a lingering, incomplete key binding (mle-cancel). This command needs to be assigned to a single-letter control code in order to become recognized and executed during input of a key-sequence (only three single-letter control codes can be used for that shortcut purpose). This control code may also be part of a multi-byte sequence, but if a sequence is active and the very control code is currently also an expected input, then the active sequence takes precedence and will consume the control code.\c\— ([Option]ally context-dependent) Invokes the commandz+.\c]— ([Option]ally context-dependent) Invokes the commandz$.\c^— ([Option]ally context-dependent) Invokes the commandz0.\c_— Cut the characters from the one after the cursor to the succeeding word boundary (mle-snarf-word-fwd).\c?— Backspace:mle-del-bwd.mle-bell— ring the audible bell.mle-clear-screen—[Option]move the cursor home and clear the screen.mle-fullreset— different tomle-resetthis will immediately reset a possibly active search etc.mle-go-screen-bwd— move the cursor backward one screen width.mle-go-screen-fwd— move the cursor forward one screen width.mle-raise-quit—raise(3)SIGQUIT.
🌈 Coloured display 💅
[Option] Colours and font attributes through ANSI — a.k.a. ISO 6429 SGR (select graphic rendition) — escape sequences are optionally supported ✨. Whether you actually get colours and font attributes depends solely upon the capability of the detected terminal type (TERM), and as fine-tuned through termcap. Colours and font attributes can be managed with the multiplexer command colour, and uncolour removes the given mappings. Setting colour-disable suppresses usage of colour and font attribute sequences, while leaving established mappings unchanged 🫶.
Whether actually applicable colour and font attribute sequences should also be generated when output is going to be paged through the external PAGER (also see crt) depends upon the setting of colour-pager, because pagers usually need to be configured in order to support ISO escape sequences 😭. Knowledge of some widely used pagers is however built-in, and in a clean environment it's often enough to simply set colour-pager; please refer to that variable for more on this topic 👑
It might make sense to conditionalize colour setup on interactive mode via if ('terminal' indeed means "interactive"):
if terminal && "$features" =% ,+colour,
colour iso view-msginfo ft=bold,fg=green
colour iso view-header ft=bold,fg=red (from|subject) # regex
colour iso view-header fg=red
uncolour iso view-header from,subject
colour iso view-header ft=bold,fg=magenta,bg=cyan
colour 256 view-header ft=bold,fg=208,bg=230 "subject,from"
colour mono view-header ft=bold
colour mono view-header ft=bold,ft=reverse subject,from
endif
🛡️ Handling spam 🛡️
[Option] S-nail can make use of several spam interfaces for the purpose of identification of, and, in general, dealing with spam messages. A precondition of most commands in order to function is that the spam-interface variable is set to one of the supported interfaces. "Specifying messages" that have been identified as spam is possible via their (volatile) 'is-spam' state by using the :s and :S specifications, and their attrlist entries will be used when displaying the headline in the summary of headers 🌸
spamraterates the given messages and sets their'is-spam'flag accordingly. If the spam interface offers spam scores these can be shown in headline by using the format%$.spamham,spamspamandspamforgetwill interact with the Bayesian filter of the chosen interface and learn the given messages as "ham" or "spam", respectively; the last command can be used to cause "unlearning" of messages; it adheres to their current'is-spam'state and thus reverts previous teachings 🔥spamclearandspamsetwill simply set and clear, respectively, the mentioned volatile'is-spam'message flag, without any interface interaction.
The spamassassin(1) based spam-interface spamc requires a running instance of the spamd(1) server in order to function, started with the option --allow-tell shall Bayesian filter learning be possible:
$ spamd -i localhost:2142 -i /tmp/.spamsock -d [-L] [-l]
$ spamd --listen=localhost:2142 --listen=/tmp/.spamsock \
--daemonize [--local] [--allow-tell]
Thereafter S-nail can make use of these interfaces:
$ s-nail -Sspam-interface=spamc -Sspam-maxsize=500000 \
-Sspamc-command=/usr/local/bin/spamc \
-Sspamc-arguments="-U /tmp/.spamsock" -Sspamc-user=
or
$ s-nail -Sspam-interface=spamc -Sspam-maxsize=500000 \
-Sspamc-command=/usr/local/bin/spamc \
-Sspamc-arguments="-d localhost -p 2142" -Sspamc-user=
Using the generic filter approach allows usage of programs like bogofilter(1). Here is an example, requiring it to be accessible via PATH:
$ s-nail -Sspam-interface=filter -Sspam-maxsize=500000 \
-Sspamfilter-ham="bogofilter -n" \
-Sspamfilter-noham="bogofilter -N" \
-Sspamfilter-nospam="bogofilter -S" \
-Sspamfilter-rate="bogofilter -TTu 2>/dev/null" \
-Sspamfilter-spam="bogofilter -s" \
-Sspamfilter-rate-scanscore="1;^(.+)$"
Okay so real talk 💅 — messages have to actually exist on local storage before they can be scored, or used for training a Bayesian filter. So like… it's possibly a good idea to do the local spam check last? Makes sense bestie. And you can have spam checked automatically whenever you open specific folders, by setting a specialized form of the internal variable folder-hook:
define spamdelhook {
# Server side DCC
spamset (header x-dcc-brand-metrics "bulk")
# Server-side spamassassin(1)
spamset (header x-spam-flag "YES")
del :s # TODO we HAVE to be able to do `spamrate :u ! :sS'
move :S +maybe-spam
spamrate :u
del :s
move :S +maybe-spam
}
set folder-hook-SOMEFOLDER=spamdelhook
See also the documentation for the variables spam-interface, spam-maxsize, spamc-command, spamc-arguments, spamc-user, spamfilter-ham, spamfilter-noham, spamfilter-nospam, spamfilter-rate and spamfilter-rate-scanscore. 👑
🌸 COMMANDS 🌸
S-nail reads input in lines, periodt. An unquoted reverse solidus \ hanging out at the end of a command line “escapes” the newline character — it gets yeeted and the next line of input becomes a follow-up line, with all leading whitespace removed. Once an entire line is completed, the whitespace characters space, tabulator, newline, plus whatever the variable ifs says, get stripped off the beginning and the end. And ooh ✨ — putting any whitespace characters at the very start of a line will prevent a possible addition of the command line to the [Option]al history. Sneaky but iconic.
The beginning of those input lines then gets scanned for the name of a known command. Command names can be abbreviated — in which case the first command that matches the given prefix gets used. “Command modifiers” can prefix a command to modify its behaviour. A name can also be a commandalias, and that'll keep getting expanded until no more expansion is possible. Once the command that shall be executed is known, the rest of the input line gets interpreted according to command-specific rules, documented down below. 🦋
Lowkey important heads-up: this behaviour is different to the sh(1)ell, which is a programming language with syntactic elements of clearly defined semantics, and therefore capable of sequentially expanding and evaluating individual elements of a line. Like, ? set one=value two=$one for example will never possibly assign value to one, because the variable assignment is performed no sooner but by the command (set), long after the expansion happened. Not me being caught out by that 🙈.
A list of all commands in lookup order is dumped by the command list. [Option]ally the command help (or ?), when given an argument, will show a documentation string for the command matching the expanded argument — as in ?t, which should be a shorthand of ?type. With these documentation strings both commands support a more verbose listing mode which includes the argument type of the command and other information which applies. So a handy suggestion might thus be:
? define __xv {
# Before v15: need to enable sh(1)ell-style on _entire_ line!
localopts yes;wysh set verbose;ignerr eval "${@}";return ${?}
}
? commandalias xv '\call __xv'
? xv help set
💅 Command modifiers
Commands may be prefixed by none to multiple command modifiers. Some command modifiers can be used with a restricted set of commands only — the verbose version of list will ([Option]ally) show which modifiers apply.
- The modifier reverse solidus
\, to be placed first, preventscommandaliasexpansions on the remains of the line. So like\echowill always evaluate the commandecho, even if a (command)aliasof the same name exists.commandaliascontent may itself contain further command modifiers, including an initial reverse solidus to prevent further expansions. 🎀 - The modifier
ignerrindicates that any error generated by the following command should be ignored by the state machine and not cause a program exit with enablederrexitor for the standardized exit cases inposixmode.?, one of the “INTERNAL VARIABLES”, will be set to the real exit status of the command regardless. no cap. localwill alter the called command to apply changes only temporarily, local to block-scope, and can thus only be used inside of a defined macro or anaccountdefinition. Specifying it implies the modifierwysh. Local variables will not be inherited by macros deeper in the call chain, and all local settings will be garbage collected once the local scope is left. To record and unroll changes in the global scope use the commandlocalopts.scopedoes yet not implement any functionality. (it's giving placeholder energy 💀)udoes yet not implement any functionality. (same bestie, same)- Some commands support the
vputmodifier: if used, they expect the name of a variable — which can itself be a variable, i.e., shell expansion is applied — as their first argument, and will place their computation result in it instead of the default location (it is usually written to standard output).
The given name will be tested for being a valid sh(1) variable name, and may therefore only consist of upper- and lowercase characters, digits, and the underscore; the hyphen-minus may be used as a non-portable extension; digits may not be used as first, hyphen-minus may not be used as last characters. In addition the name may either not be one of the known “INTERNAL VARIABLES”, or must otherwise refer to a writable (non-boolean) value variable. The actual put operation may fail nonetheless — for example if the variable expects a number argument only a number will be accepted. Any error during these operations causes the command as such to fail, and the error number ! will be set to ^ERR-NOTSUP, the exit status ? should be set to -1, but some commands deviate from the latter, which is documented. 💖
- Last, but not least, the modifier
wyshcan be used for some old and established commands to choose the new “Shell-style argument quoting” rules over the traditional “Old-style argument quoting”. This modifier is implied ifv15-compatis set to a non-empty value. 🌈
✨ Old-style argument quoting ✨
[v15 behaviour may differ] This section documents the traditional and POSIX standardized style of quoting non-message list arguments to commands which expect this type of arguments. Whereas still used by the majority of such commands, the new “Shell-style argument quoting” may be available even for those via wysh, one of the “Command modifiers”. Nonetheless care must be taken, because only new commands have been designed with all the capabilities of the new quoting rules in mind, which can, for example, generate control characters. 🫶
- An argument can be enclosed between paired double-quotes
"argument"or single-quotes'argument'; any whitespace, shell word expansion, or reverse solidus characters (except as described next) within the quotes are treated literally as part of the argument. A double-quote will be treated literally within single-quotes and vice versa. Inside such a quoted string the actually used quote character can be used nonetheless by escaping it with a reverse solidus\, as in"y\"ou". - An argument that is not enclosed in quotes, as above, can usually still contain space characters if those spaces are reverse solidus escaped, as in
you\ are. - A reverse solidus outside of the enclosing quotes is discarded and the following character is treated literally as part of the argument.
🦋 Shell-style argument quoting 🦋
sh(1)ell-style, and therefore POSIX standardized, argument parsing and quoting rules are used by most commands. [v15 behaviour may differ] Most new commands only support these new rules and are flagged [Only new quoting rules], some elder ones can use them with the command modifier wysh; in the future only this type of argument quoting will remain. slay 💅
A command line is parsed from left to right and an input token is completed whenever an unquoted, otherwise ignored, metacharacter is seen. Metacharacters are vertical bar |, ampersand &, semicolon ;, as well as all characters from the variable ifs, and / or space, tabulator, newline. The additional metacharacters left and right parenthesis (, ) and less-than and greater-than signs <, > that the sh(1) supports are not used, and are treated as ordinary characters: for one these characters are a vivid part of email addresses, and it seems highly unlikely that their function will become meaningful to S-nail. 👑
Compatibility note:[v15 behaviour may differ]Please note that even many new-style commands do not yet honourifsto parse their arguments: whereas thesh(1)ell is a language with syntactic elements of clearly defined semantics, S-nail parses entire input lines and decides on a per-command base what to do with the rest of the line. This also means that whenever an unknown command is seen all that S-nail can do is cancellation of the processing of the remains of the line. It also often depends on an actual subcommand of a multiplexer command how the rest of the line should be treated, and until v15 we are not capable to perform this deep inspection of arguments. Nonetheless, at least the following commands which work with positional parameters fully supportifsfor an almost shell-compatible field splitting:call,call_if,read,vpospar,xcall.
Any unquoted number sign # at the beginning of a new token starts a comment that extends to the end of the line, and therefore ends argument processing. An unquoted dollar sign $ will cause variable expansion of the given name, which must be a valid sh(1)ell-style variable name (see vput): “INTERNAL VARIABLES” as well as “ENVIRONMENT” (shell) variables can be accessed through this mechanism, brace enclosing the name is supported (i.e., to subdivide a token). 🌸
Okay so, the metacharacters space, tabulator and newline? They only complete an input token, that's literally all they do. But vertical bar |, ampersand & and semicolon ; are a whole different vibe — they're control operators and they actually perform control functions. Rn the only one supported is the semicolon ;, which terminates a single command, so it sequences the command line and makes the remainder of the line a subject to reevaluation. And with sequencing, multiple command argument types and quoting rules can all apply to one single line, which could get problematic before v15 — like, the first of these two will cause surprising results 🫠
? echo one; set verbose; echo verbose=$verbose.
? echo one; wysh set verbose; echo verbose=$verbose.
Quoting is the mechanism that removes the special meaning of metacharacters and reserved words, and it prevents expansion. There are four quoting mechanisms bestie: the escape character, single-quotes, double-quotes and dollar-single-quotes:
- The literal value of any character can be preserved by preceding it with the escape character reverse solidus
\. - Arguments which are enclosed in
'single-quotes'retain their literal value. A single-quote cannot occur within single-quotes. (🙈 rude but true) - The literal value of all characters enclosed in
"double-quotes"is retained, with the exception of dollar sign$, which will cause variable expansion, as above, backquote (grave accent)`, (which not yet means anything special), reverse solidus\, which will escape any of the characters dollar sign$(to prevent variable expansion), backquote (grave accent)`, double-quote"(to prevent ending the quote) and reverse solidus\(to prevent escaping, i.e., to embed a reverse solidus character as-is), but has no special meaning otherwise. - Arguments enclosed in
$'dollar-single-quotes'extend normal single quotes in that reverse solidus escape sequences are expanded as follows:\a— bell control character (ASCII and ISO-10646 BEL).\b— backspace control character (ASCII and ISO-10646 BS).\E— escape control character (ASCII and ISO-10646 ESC).\e— the same.\f— form feed control character (ASCII and ISO-10646 FF).\n— line feed control character (ASCII and ISO-10646 LF).\r— carriage return control character (ASCII and ISO-10646 CR).\t— horizontal tabulator control character (ASCII and ISO-10646 HT).\v— vertical tabulator control character (ASCII and ISO-10646 VT).\\— emits a reverse solidus character.\'— single quote.\"— double quote (escaping is optional).\NNN— eight-bit byte with the octal valueNNN(one to three octal digits), optionally prefixed by an additional0. A 0 byte will suppress further output for the quoted argument.\xHH— eight-bit byte with the hexadecimal valueHH(one or two hexadecimal characters, no prefix, seevexpr). A 0 byte will suppress further output for the quoted argument.\UHHHHHHHH— the Unicode / ISO-10646 character with the hexadecimal codepoint valueHHHHHHHH(one to eight hexadecimal characters) — note that Unicode defines the maximum codepoint ever to be supported as0x10FFFF(in planes of0xFFFFcharacters each). This escape is only supported in locales that support Unicode (see “Character sets”), in other cases the sequence will remain unexpanded unless the given code point is ASCII compatible or (if the[Option]al character set conversion is available) can be represented in the current locale. The character NUL will suppress further output for the quoted argument.\uHHHH— Identical to\UHHHHHHHHexcept it takes only one to four hexadecimal characters.\cX— Emits the non-printable (ASCII and compatible) C0 control codes 0 (NUL) to 31 (US), and 127 (DEL). Printable representations of ASCII control codes can be created by mapping them to a different, visible part of the ASCII character set. Adding the number 64 achieves this for the codes 0 to 31, here 7 (BEL):7 + 64 = 71 = G. The real operation is a bitwise logical XOR with 64 (bit 7 set, seevexpr), thus also covering code 127 (DEL), which is mapped to 63 (question mark):? vexpr ^ 127 64.
Now, historically circumflex notation has often been used for visualization purposes of control codes, as in ^G, but the reverse solidus notation has been standardized: \cG. Some control codes also have standardized (ISO-10646, ISO C) aliases, as shown above (\a, \n, \t etc): whenever such an alias exists it will be used for display purposes. The control code NUL (\c@, a non-standard extension) will suppress further output for the remains of the token (which may extend beyond the current quote), or, depending on the context, the remains of all arguments for the current command. 😳
\$NAME— Non-standard extension: expand the given variable name, as above. Brace enclosing the name is supported.\`{command}— Not yet supported, just to raise awareness: Non-standard extension.
Caveats 💀
? echo 'Quotes '${HOME}' and 'tokens" differ!"# no comment
? echo Quotes ${HOME} and tokens differ! # comment
? echo Don"'"t you worry$'\x21' The sun shines on us. $'\u263A'
💬 Message list arguments
So many commands operate on message list specifications, as documented in “Specifying messages”. The argument input is first split into individual tokens via “Shell-style argument quoting”, which are then interpreted as the mentioned specifications. If no explicit message list has been specified, many commands will search for and use the next message forward that satisfies the commands' requirements, and if there are no messages forward of the current message, the search proceeds backwards — and if there are no good messages at all to be found, an error message is shown and the command is aborted, no cap. The verbose output of the command list will indicate whether a command searches for a default message, or not. 🔍
🧬 Raw data arguments for codec commands
There's a special lil set of commands, and they all have the string “codec” in their name, like addrcodec, shcodec, urlcodec — these take raw string data as input, which means the content of the command input line is passed completely unexpanded and otherwise unchanged: like this the effect of the actual codec is visible without any noise of possible shell quoting rules etc., i.e., the user can input one-to-one the desired or questionable data. And to gain a level of expansion, the entire command line can be evaluated first, for example:
? vput shcodec res encode /usr/Schönes Wetter/heute.txt
? echo $res
$'/usr/Sch\u00F6nes Wetter/heute.txt'
? shcodec d $res
$'/usr/Sch\u00F6nes Wetter/heute.txt'
? eval shcodec d $res
/usr/Schönes Wetter/heute.txt
📁 Filename transformations
Filenames, where expected, and unless documented otherwise, are subsequently subject to the following filename transformations, in sequence:
- If the given name is a registered shortcut, it will be replaced with the expanded shortcut. This step is mostly taken for folders only.
- The filename is matched against the following patterns or strings. But for plus
+filefolder expansion this step is mostly taken for folders only.#— (Number sign) is expanded to the previous file.%— (Percent sign) is replaced by the invoking user's primary system mailbox, which either is the (itself expandable)inboxif that is set, the standardized absolute pathname indicated byMAILif that is set, or a built-in compile-time default otherwise. When opening a folder the used name is actively checked for being a primary mailbox, first againstinbox, then againstMAIL.%user— Expands to the primary system mailbox of user (and never the value ofinbox, regardless of its actual setting).&— (Ampersand) is replaced with the invoking user's secondary mailbox, theMBOX.+file— Refers to a file in the folder directory (if that variable is set).%:filespec— Expands to the same value as filespec, but has special meaning when used with, for example, the commandfolder: the file will be treated as a primary system mailbox by, among others, themboxandsavecommands, meaning that messages that have been read in the current session will be moved to theMBOXmailbox instead of simply being flagged as read.
- Meta expansions may be applied to the resulting filename, as allowed by the operation and applicable to the resulting access protocol (also see “On URL syntax and credential lookup”). For the
file-protocol, a leading tilde~character will be replaced by the expansion ofHOME, except when followed by a valid user name, in which case the home directory of the given user is used instead. ✨
A shell expansion, same energy as if you'd specified it in double-quotes (go peek “Shell-style argument quoting”) may be applied, so that any occurrence of ‘$VARIABLE’ (or ‘${VARIABLE}’) will be replaced by the expansion of that variable, if possible — and yes, “INTERNAL VARIABLES” as well as “ENVIRONMENT” (shell) variables can be accessed through this mechanism. variable inception fr fr 💫
Shell pathname wildcard pattern expansions (glob(7)) may be applied as documented. ⚠️ careful though: if the fully expanded filename results in multiple pathnames and the command is expecting only one file, an error results. your glob said slay but the command said one (1) file 😭
In interactive context, in order to allow simple value acceptance (via “ENTER”), arguments will usually be displayed in a properly quoted form, so a file ‘diet\ is \curd.txt’ may be displayed as ‘'diet\ is \curd.txt'’. aesthetic and functional, we love that 💅
Commands 🌸
The following commands are available:
!— Executes the SHELL command which follows, replacing unescaped exclamation marks with the previously executed command if the internal variablebangis set. This command supportsvputas documented in “Command modifiers”, and manages the error number!. A 0 or positive exit status?reflects the exit status of the command, negative ones that an error happened before the command was executed, or that the program did not exit cleanly, but maybe due to a signal: the error number is^ERR-CHILD, then. 🔥
In conjunction with the vput modifier the following special cases exist: a negative exit status occurs if the collected data could not be stored in the given variable, which is a ^ERR-NOTSUP error that should otherwise not occur. ^ERR-CANCELED indicates that no temporary file could be created to collect the command output at first glance. In case of catchable out-of-memory situations ^ERR-NOMEM will occur and S-nail will try to store the empty string, just like with all other detected error conditions.
#— The comment-command causes the entire line to be ignored. 📝 Note: this really is a normal command which' purpose is to discard its arguments, not a “comment-start” indicating special character, which means that for example trailing comments on a line are not possible (except for commands which use “Shell-style argument quoting”). so no sneaking a little# whateverat the end of your line, bestie, that's just not how she works 🙈+— Goes to the next message in sequence and types it (like “ENTER”). ⏭️-— Display the preceding message, or the n'th previous message if given a numeric argument n. ⏪=— Shows the message number of the current message (the “dot”) when used without arguments, that of the given list otherwise. Output numbers will be separated from each other with the first character ofifs, and followed by the first character ofif-ws, if that is not empty and not identical to the first. If that results in no separation at all a space character is used. This command supportsvput(see “Command modifiers”), and manages the error number!. 💫?— [Option] Show a brief summary of commands. [Option] Given an argument a synopsis for the command in question is shown instead; commands can be abbreviated in general and this command can be used to see the full expansion of an abbreviation including the synopsis, try, for example, ‘?h’, ‘?hel’ and ‘?help’ and see how the output changes. 👑 To avoid that aliases are resolved the modifier\can be prepended to the argument, but note it must be quoted. This mode also supports a more verbose output, which will provide the information documented forlist.|— A synonym for thepipecommand. 🚰account,unaccount— (ac,una) Creates, selects or lists (an) account(s). Accounts are special incarnations of defined macros and group commands and variable settings which together usually arrange the environment for the purpose of creating an email account. Different to normal macros settings which are covered bylocalopts— here by default enabled! — will not be reverted before the account is changed again. The special account ‘null’ (case-insensitive) always exists, and all but it can be deleted by the latter command, and in one operation with the special name ‘*’. Also for all but it a possibly seton-account-cleanuphook is called once they are left, also for program exit. 🎀
Without arguments a listing of all defined accounts is shown. With one argument the given account is activated: the system inbox of that account will be activated (as via folder), a possibly installed folder-hook will be run, and the internal variable account will be updated. The two argument form behaves identical to defining a macro as via define. Important settings for accounts include folder, from, hostname, inbox, mta, password and user (“On URL syntax and credential lookup”), as well as things like tls-config-pairs (“Encrypted network communication”), and protocol specifics like imap-auth, pop3-auth, smtp-auth.
account myisp {
set folder=~/mail inbox=+syste.mbox record=+sent.mbox
set from='(My Name) myname@myisp.example'
set mta=smtp://mylogin@smtp.myisp.example
}
addrcodec— Perform email address codec transformations on raw-data argument, rather according to email standards (RFC 5322;[v15 behaviour may differ]will furtherly improve). Supportsvput(see “Command modifiers”), and manages the error number!. The first argument must be either[+[+[+]]]e[ncode],d[ecode],s[kin]orskinl[ist]and specifies the operation to perform on the rest of the line. ✨
Decoding will show how a standard-compliant MUA will display the given argument, which should be an email address. Please be aware that most MUAs have difficulties with the address standards, and vary wildly when (comments) in parenthesis, “double-quoted” strings, or quoted-pairs, as below, become involved. [v15 behaviour may differ] S-nail currently does not perform decoding when displaying addresses. 💀
Skinning is identical to decoding but only outputs the plain address, without any string, comment etc. components. Another difference is that it may fail with the error number ! set to ^ERR-INVAL if decoding fails to find a(n) (valid) email address, in which case the unmodified input will be output again.
skinlist first performs a skin operation, and thereafter checks a valid address for whether it is a registered mailing list (see mlist and mlsubscribe), eventually reporting that state in the error number ! as ^ERR-EXIST. (This state could later become overwritten by an I/O error, though.)
Encoding supports four different modes, lesser automated versions can be chosen by prefixing one, two or three plus signs: the standard imposes a special meaning on some characters, which thus have to be transformed to so-called quoted-pairs by pairing them with a reverse solidus ‘\’ in order to remove the special meaning; this might change interpretation of the entire argument from what has been desired, however! ⚠️ so watch out Specify one plus sign to remark that parenthesis shall be left alone, two for not turning double quotation marks into quoted-pairs, and three for also leaving any user-specified reverse solidus alone. The result will always be valid, if a successful exit status is reported ([v15 behaviour may differ] the current parser fails this assertion for some constructs). [v15 behaviour may differ] Addresses need to be specified in between angle brackets ‘<’, ‘>’ if the construct becomes more difficult, otherwise the current parser will fail; it is not smart enough to guess right. 🙈
? addrc enc "Hey, you",<diet@exam.ple>\ out\ there
"\"Hey, you\", \\ out\\ there" <diet@exam.ple>
? addrc d "\"Hey, you\", \\ out\\ there" <diet@exam.ple>
"Hey, you", \ out\ there <diet@exam.ple>
? addrc s "\"Hey, you\", \\ out\\ there" <diet@exam.ple>
diet@exam.ple
alias,unalias—[Only new quoting rules](a,una) Define or list, and remove, respectively, address aliases, which are a method of creating personal distribution lists that map a single name to none to multiple receivers, to be expanded after “Compose mode” is left; the expansion correlates withmetoo. The latter command removes all given aliases, the special name asterisk ‘*’ will remove all existing aliases. When used without arguments the former shows a list of all currently known aliases, with one argument only the target(s) of the given one. When given two arguments, hyphen-minus ‘-’ being the first, the target(s) of the second is/are expanded recursively. 🦋
In all other cases the given alias is newly defined, or will be appended to: arguments must either be themselves valid alias names, or any other address type (see “On sending mail, and non-interactive mode”). Recursive expansion of aliases can be prevented by prefixing the desired argument with the modifier reverse solidus \. A valid alias name conforms to mta-aliases syntax, but follow-up characters can also be the number sign ‘#’, colon ‘:’, commercial at ‘@’, exclamation mark ‘!’, period ‘.’ as well as “any character that has the high bit set”. The dollar sign ‘$’ may be the last character. The number sign ‘#’ may need “Shell-style argument quoting”.
[v15 behaviour may differ] so like… the colon?? Legit not supported right now, bestie. 😭 It's out here feuding with the normal address parsing rules, that's the whole drama, that's the entire reason.
[v15 behaviour may differ] and those high bit characters? They're highkey gonna cause warnings at the moment too, for the exact same reasons why the colon is unsupported — plus, plot twist for the future: locale dependent character set validity checks will be performed as well. ⭐
? alias cohorts bill jkf mark kridle@ucbcory ~/cohorts.mbox
? alias mark mark@exam.ple
? set mta-aliases=/etc/aliases
🦋 alternates, unalternates 🦋
[Only new quoting rules] (alt) okay so this one manages a whole list of alternate addresses or names of the active user — and anybody on that list gets yanked out of recipient lists (except one, bestie, always one survivor 💅).
There's a lil set of implicit alternates that just… exists, formed from the values of LOGNAME, from, sender and reply-to. And heads up: from will not be used if sender is set. no cap.
The latter command (unalternates) removes the given list of alternates, and the special name '*' will straight-up discard all existing alternate names. poof. gone. 🫶
The former command (alternates) manages the error number !. Used with no arguments, it shows you the current set of alternates — and in this mode only, it also supports vput (go peek at “Command modifiers”, iykyk). Otherwise, the given arguments (after being checked for validity, bestie, we're validating ✨) get appended to the list of alternate names — except in posix mode, where they replace that list instead. different vibe, same command.
🌸 answered, unanswered 🌸
Take a message lists and mark each message as (not) having been answered. That's it, that's the job.
Messages will be marked answered automatically when being replyd to, if the markanswered variable is set. Slay. See the section “Message states” for the lore.
💅 bind, unbind 💅
[Option][Only new quoting rules] The bind command extends the MLE (see “On terminal control and line editor”) with freely configurable key bindings, which is honestly iconic of it. The latter command, unbind, removes from the given context the given key binding — and both of those things can be specified as a wildcard '*', so that unbind * * will remove all bindings of all contexts. total wipeout. 💀
But also: due to initialization order, unbinding will not work for built-in key bindings upon program startup. fr fr. Please use line-editor-no-defaults for this purpose instead, bestie. 🙈
With zero arguments, or with a context name, the former command shows all key bindings (of the given context; an asterisk '*' will iterate over all contexts) — and a more verbose listing will be produced if either of debug or verbose are set. ✨
With two or more arguments, a specific binding is shown, or (re)established: the first argument is the context to which the binding shall apply, the second argument is a comma-separated list of the “keys” which form the binding. Further arguments will be joined to form the expansion, and cause the binding to be created or updated.
To indicate that a binding shall not be auto-committed, but that the expansion shall instead be furtherly editable by the user, a commercial at '@' (that will be removed) can be placed last in the expansion — from which leading and trailing whitespace will finally be removed. Reverse solidus cannot be used as the last character of expansion. And an empty expansion will be rejected. periodt.
Contexts define when a binding applies, i.e., a binding will not be seen unless the context for which it is defined for is currently active. This is not true for the shared binding 'base', which is the foundation for all other bindings and as such always applies — its bindings, however, only apply secondarily. The available contexts are:
- the shared
'base' - the
'default'context, which is used in all not otherwise documented situations 'compose', which applies only to “Compose mode”
Bindings are specified as a comma-separated list of byte-sequences, where each list entry corresponds to one “key” (press). Byte sequence boundaries will be forcefully terminated after bind-inter-byte-timeout milliseconds, whereas key sequences can be timed out via bind-inter-key-timeout.
A list entry may, indicated by a leading colon character ':', also refer to the name of a terminal capability; several dozen names are compiled in and may be specified either by their terminfo(5), or, if existing, by their termcap(5) name, regardless of the actually used [Option]al terminal control library. But any capability may be used, as long as the name is resolvable by the [Option]al control library, or was defined via the internal variable termcap.
Input sequences are not case-normalized, an exact match is required to update or remove a binding. It is advisable to use an initial escape or other control character (like '\cA') for user (as opposed to purely terminal capability based) bindings in order to avoid ambiguities; it also reduces search time. 💅 Examples:
? bind base a,b echo one
? bind base $'\E',d mle-snarf-word-fwd # Esc(ape)
? bind base $'\E',$'\c?' mle-snarf-word-bwd # Esc,Delete
? bind default $'\cA',:khome,w 'echo Editable binding@'
? bind default a,b,c rm -irf / @ # Also editable
? bind default :kf1 File %
? bind compose :kf1 ~v
Note that the entire comma-separated list is first parsed (over) as a shell-token with whitespace as the field separator, then parsed and expanded for real with comma as the field separator — therefore whitespace needs to be properly quoted, see “Shell-style argument quoting”. Using Unicode reverse solidus escape sequences renders a binding defunctional if the locale does not support Unicode (see “Character sets”), and using terminal capabilities does so if no (corresponding) terminal control support is (currently) available. 😭
Adding, deleting or modifying a key binding invalidates the internal prebuilt lookup tree — it will be recreated as necessary, and this process will be visualized in most verbose as well as in debug mode. 🎀
The following terminal capability names are built-in and can be used in terminfo(5) or (if available) the two-letter termcap(5) notation. See the respective manual for a list of capabilities. The program infocmp(1) can be used to show all the capabilities of TERM or the given terminal type; using the -x flag will also show supported (non-standard) extensions. 👑
kbsorkb— Backspace.kdch1orkD— Delete character.kDCor*4— shifted variant.kelorkE— Clear to end of line.kextor@9— Exit.kich1orkI— Insert character.kICor#3— shifted variant.khomeorkh— Home.kHOMor#2— shifted variant.kendor@7— End.knporkN— Next page.kpporkP— Previous page.kcub1orkl— Left cursor (with more modifiers: see below).kLFTor#4— shifted variant.kcuf1orkr— Right cursor (ditto).kRITor%i— shifted variant.kcud1orkd— Down cursor (ditto).kDN— shifted variant (only terminfo).kcuu1orku— Up cursor (ditto).kUP— shifted variant (only terminfo).kf0ork0— Function key 0. Add one for each function key up tokf9andk9, respectively.kf10ork;— Function key 10.kf11orF1— Function key 11. Add one for each function key up tokf19andF9, respectively.
Some terminals support key-modifier combination extensions, e.g., 'Alt+Shift+xy'. For example, the delete key, kdch1: in its shifted variant, the name is mutated to kDC, then a number is appended for the states 'Alt' (kDC3), 'Shift+Alt' (kDC4), 'Control' (kDC5), 'Shift+Control' (kDC6), 'Alt+Control' (kDC7), finally 'Shift+Alt+Control' (kDC8). The same for the left cursor key, kcub1: KLFT, KLFT3, KLFT4, KLFT5, KLFT6, KLFT7, KLFT8. 😌✨
🎀 call 🎀
[Only new quoting rules] Calls the given macro, which must have been created via define (see there for more, bestie 👀) — otherwise an ^ERR-NOENT error occurs.
Calling macros recursively will at some time excess the stack size limit, causing a hard program abortion. 💀💀
If recursively calling a macro is the last command of the current macro, consider to use the command xcall, which will first release all resources of the current macro before replacing the current macro with the called one. do it for the stack, bestie. 🫶
🌈 call_if 🌈
Identical to call if the given macro has been created via define — but it does not fail nor warn if the macro does not exist. chill. no drama. no warnings. 💜
⭐ cd ⭐
Synonym for chdir. that's it, that's the whole section. slay. 💅
🔥 certsave 🔥
[Option] Only applicable to S/MIME signed messages. Takes an optional message list and a filename, and saves the certificates contained within the message signatures to the named file in both human-readable and PEM format. ✨
The certificates can later be used to send encrypted messages to the respective message senders by setting smime-encrypt-USER@HOST variables. obsessed with the foresight honestly. 🎀
🧚 charsetalias, uncharsetalias 🧚
[Only new quoting rules] Manage alias mappings for (conversion of) “Character sets”. Alias processing is not performed for “INTERNAL VARIABLES”, for example charset-8bit, and mappings are ineffective if character set conversion is not available (features does not announce ',+iconv,'). 🙈
Expansion happens recursively for cases where aliases point to other aliases (built-in loop limit: 8). 💫
The latter command — bestie that's unalias — yeets every alias you hand it as an argument, or just nukes the whole collection at once if you give it the asterisk *. And the former, aka alias, when you call it with zero arguments, shows you the full list of everything currently defined. Give it exactly one argument and it shows you the target of that one. Give it two arguments where the hyphen-minus - is the first one, and the second one gets expanded recursively instead. In literally every other case, the arguments you pass are treated as pairs — character sets and the target alias name you want them to become — and that's how new aliases get born or existing ones get glow-ups. 💅
🦋 chdir
(Only new quoting rules) Changes the working directory to HOME, or to whatever argument you give it. It's a straight-up synonym for cd. Same vibes, different spelling. 🫶
🔥 collapse, uncollapse
Only applicable when you're in threaded sort mode, periodt. Takes a message list and makes every reply to those messages invisible in header summaries — except for new messages and the “dot”. Also: when a message that has collapsed replies gets displayed, all of those replies get uncollapsed automatically, no cap. The latter command (uncollapse) is the undo button for the collapsing. 🔁
🎀 colour, uncolour
(Option-gated! Only new quoting rules!) Manage colour mappings of and for a “Coloured display”. Without arguments, the former shows you every currently defined mapping. Otherwise it expects a colour type (case-insensitive, obviously), and it has to be one of:
256— for 256-colour terminals 🌈8,ansioriso— for the standard 8-colour ANSI / ISO 6429 colour palette 🎨1ormono— for monochrome terminals, which only support (some) font attributes 💀
Without further arguments, the list of all currently defined mappings of that given type gets shown — and here the special all or * also show all currently defined mappings.
Otherwise? Then the second argument defines the mappable slot, the third argument is a (comma-separated list of) colour and font attribute specification(s), and the optionally supported fourth argument lets you specify a precondition. If conditioned mappings exist they get tested in (creation) order unless a (case-insensitive) match has already been found, and the default mapping (if any has been established) will only be chosen as a last resort. The types of available preconditions depend on the mappable slot, and these are the ones that exist:
- Mappings prefixed with
mle-are used for the (Option-gated) built-in Mailx-Line-Editor (MLE, see “On terminal control and line editor”) and they do NOT support preconditions.mle-position— this mapping is used for the position indicator that's visible when a line can't be fully displayed on the screen.mle-prompt— used for the prompt.mle-error— used for the occasionally appearing error indicator that gets joined onto the prompt. [v15 behaviour may differ] Also used for error messages written on standard error.
- Mappings prefixed with
sum-are used in header summaries, and all of them understand the preconditionsdot(the current message) andolderfor elder messages (only honoured in conjunction withdatefield-markout-older).sum-dotmark— this mapping is used for the “dotmark” that can be created with the%>or%<formats of the variableheadline.sum-header— for the complete header summary line except the “dotmark” and the thread structure.sum-thread— for the thread structure, which can be created with the%iformat of the variableheadline.
- Mappings prefixed with
view-are used when displaying messages.view-from_— this mapping is used for so-calledFrom_lines, which are MBOX file format specific header lines (also seembox-rfc4155).view-header— for header lines. A comma-separated list of headers to which the mapping applies may be given as a precondition; if the (Option-gated) regular expression support is available, then if any of the “magic regular expression characters” is seen, the precondition will be evaluated as (an extended) one.view-msginfo— for the introductional message info line.view-partinfo— for MIME part info lines.
The following (case-insensitive) colour definitions and font attributes are understood, and you can stack multiple of them in a comma-separated list:
ft=— a font attribute:bold,reverseorunderline. It's possible (and often applicable) to specify multiple font attributes for a single mapping. ✨fg=— foreground colour attribute, in order (numbers 0 - 7):black,red,green,brown,blue,magenta,cyanorwhite. To specify a 256-colour mode, a decimal number colour specification in the range 0 to 255, inclusive, is supported, and interpreted like this:0 - 7— the standard ISO 6429 colours, as above.8 - 15— high intensity variants of the standard colours.16 - 231— 216 colours in tuples of 6.232 - 255— grayscale from black to white in 24 steps.
#!/bin/sh -
fg() { printf "\033[38;5;${1}m($1)"; }
bg() { printf "\033[48;5;${1}m($1)"; }
i=0
while [ $i -lt 256 ]; do fg $i; i=$(($i + 1)); done
printf "\033[0m\n"
i=0
while [ $i -lt 256 ]; do bg $i; i=$(($i + 1)); done
printf "\033[0m\n"
bg=— background colour attribute (seefg=for possible values).
The command uncolour will remove, for the given colour type (the special type * selects all), the given mapping; if the optional precondition argument is given, only the exact tuple of mapping and precondition is removed. The special name * will remove all mappings (no precondition allowed), thus uncolour * * will remove all established mappings. 💀✨
💜 commandalias, uncommandalias
(Only new quoting rules) Define or list, and remove, respectively, command aliases. A (command)alias can be used everywhere a normal command can be used, but it always takes precedence: any arguments that are given to the command alias get joined onto the alias expansion, and the resulting string forms the command line that is, in effect, executed. The latter command removes all given aliases, and the special name asterisk * will remove all existing aliases. When used without arguments, the former shows a list of all currently known aliases; with one argument, it shows only the expansion of the given one.
With two or more arguments a command alias is defined or updated: the first argument is the name under which the remaining command line should be accessible, and the content of that can be just about anything. An alias may itself expand to another alias, but to avoid expansion loops, further expansion will be prevented if an alias refers to itself or if an expansion depth limit is reached. Explicit expansion prevention is available via reverse solidus \, one of the “Command modifiers”. 🌀
? commandalias xx
s-nail: `commandalias': no such alias: xx
? commandalias xx echo hello,
? commandalias xx
commandalias xx 'echo hello,'
? xx
hello,
? xx world
hello, world
👑 Copy
(C) — Similar to copy, but it copies the messages to a file named after the local part of the sender of the first message instead of taking a filename argument; outfolder is inspected to decide on the actual storage location. 📬
💖 copy
(c) — Copies messages to the named file and does not mark them as being saved; otherwise identical to save.
🧚 csop
(Only new quoting rules) A multiplexer command which provides C-style string operations on 8-bit bytes with no notion of locale settings and character sets — effectively assuming ASCII data. For numeric and other operations, refer to vexpr. vput, one of the “Command modifiers”, is supported. The error result is -1 for usage errors and numeric results, and the empty string otherwise; missing data errors, as for unsuccessful searches, result in the ! error number being set to ^ERR-NODATA. Where the question mark ? modifier suffix is supported, a case-insensitive (ASCII mapping) operation mode is supported; the keyword case is optional so that find? and find?case are identical. 🫶
length— Queries the length of the given argument.hash,hash32— Calculates a hash value of the given argument. The latter will return a 32-bit result regardless of host environment. The?modifier suffix is supported. These use Chris Torek's hash algorithm, and the resulting hash value is bit mixed as shown by Bret Mulvey. 🔢find— Search for the second in the first argument. Shows the resulting 0-based offset shall it have been found. The?modifier suffix is supported. 🔍
substring
Makes a lil substring out of its first argument 💇♀️ The optional second argument is the 0-based starting offset — and if it's negative, it counts from the end (backwards bestie energy). The optional third argument sets the length of the result you want; a negative length leaves off that many bytes at the tail end of the original string. And by default? The whole entire string, no cuts. ✨
This operation tries to work around faulty arguments (set verbose if you want the error logs 👀), but it still reports them via the error number ! as ^ERR-OVERFLOW.
trim
Trims away whitespace characters from both ends of the argument. Clean. Detangled. 🎀
trim-front
Trims away whitespace characters from the beginning of the argument.
trim-end
Trims away whitespace characters from the end of the argument.
cwd
Shows the name of the current working directory, exactly as reported by getcwd(3) 📍 Supports vput (go look at “Command modifiers”). The return status is tracked via ?.
Decrypt
[Option] For unencrypted messages this command is identical to Copy; encrypted messages get decrypted first, if possible, and then copied. 🕵️♀️
decrypt
[Option] For unencrypted messages this command is identical to copy; encrypted messages get decrypted first, if possible, and then copied. (Yes bestie, lowercase version, same deal, different letters. 💅)
define, undefine
undefine deletes the given macro — and the special name '*' will discard all existing macros, like a full factory reset bestie 💀 Deletion of (a) macro(s) can be performed from within running (a) macro(s), including self-deletion (macro doing the deleting of itself, iconic, unhinged, we love it).
Without arguments, define prints the current list of macros, content included. Otherwise it defines a macro, replacing an existing one of the same name as applicable.
A defined macro can be invoked explicitly by using the call, call_if and xcall commands, or implicitly if a macro hook is triggered, for example a folder-hook. Execution of a macro body can be stopped from within by calling return. 🛑
Temporary macro block-scope variables can be created or deleted with the local command modifier in conjunction with the commands set and unset, respectively. To enforce unrolling of changes made to (global) “INTERNAL VARIABLES” the command localopts can be used instead; its covered scope depends on how (i.e., “as what”: normal macro, folder hook, hook, account switch) the macro is invoked.
Inside a called macro, the given positional parameters are implicitly local to the macro's scope, and may be accessed via the variables *, @, # and 1 and any other positive unsigned decimal number less than or equal to #. Positional parameters can be shifted, or become completely replaced, removed etc. via vpospar. A helpful command for numeric computation and string evaluations is vexpr, csop offers C-style byte string operations.
define name {
command1
command2
...
commandN
}
define exmac {
echo Parameter 1 of ${#} is ${1}, all: ${*} / ${@}
return 1000 0
}
call exmac Hello macro exmac!
echo ${?}/${!}/${^ERRNAME}
delete, undelete
(d, u) Marks the given message list as being or not being ‘deleted’, respectively 🗑️ If no argument has been specified then the usual search for a visible message is performed, as documented for “Message list arguments”, showing only the next input prompt if the search fails.
Deleted messages will neither be saved in the “secondary mailbox” MBOX nor will they be available for most other commands. So like... they're gone gone, bestie. 😭 If the autoprint variable is set, the new “dot” or the last message restored, respectively, is automatically typed; also see dp, dt.
digmsg
[Only new quoting rules] Digging (information out of) messages is possible through digmsg objects, which can be created for the given message number 🔍 In “Compose mode” the hyphen-minus - will instead open the message that is being composed.
If a hyphen-minus is given as the optional third argument then output will be generated on the standard output channel instead of being subject to consumption by the readall (or read and readsh) command(s).
⚠️ Note: output must be consumed before normal processing can continue; fordigmsgobjects this means each command output has to be read until the end of file (EOF) state occurs. No skipping, babes.
The objects may be removed again by giving the same identifier used for creation; this step could be omitted: objects will be automatically closed when the active folder (mailbox) or the compose mode is left, respectively. In all other use cases the second argument is an object identifier, and the third and all following arguments are interpreted as via ~^ (see “COMMAND ESCAPES”):
? vput = msgno; digmsg create $msgno
? digmsg $msgno header list; readall x; echon $x
210 Subject From To Message-ID References In-Reply-To
? digmsg $msgno header show Subject;readall x;echon $x
212 Subject
'Hello, world'
? digmsg remove $msgno
discard
(di) Identical to ignore. Superseded by the multiplexer headerpick. 🫡
dp, dt
Delete the given messages and automatically type the new “dot” if one exists — regardless of the setting of autoprint. Not asking, just doing. 👑
dotmove
Move the “dot” up or down by one message when given + or - argument, respectively. ⬆️⬇️
draft, undraft
Take message lists and mark each given message as being draft, or not being draft, respectively, as documented in the section “Message states”. ✍️
echo
[Only new quoting rules] (ec) Print the given strings, equivalent to the shell utility echo(1) — that is, “Shell-style argument quoting” expansion is performed and, different to the otherwise identical echon, a trailing newline is echoed. 📢 vput as documented in “Command modifiers” is supported, and the error number ! is managed: if data is stored in a variable then the return value reflects the length of the result string in case of success and is '-1' on error.
Remarks: this command traditionally (in BSD Mail) also performed “Filename transformations”, which is standard incompatible and hard to handle because quoting transformation patterns is not possible; the subcommand file-expand of vexpr can be used to expand filenames. 🧚
echoerr
[Only new quoting rules] Identical to echo, but the message is written to standard error, and prefixed by log-prefix. Also see echoerrn. In interactive sessions the [Option]al message ring queue for errors will be used instead, if available and vput was not used. 🚨
echon
[Only new quoting rules] Identical to echo, but does not write or store a trailing newline. No newline, no problem. ✨
echoerrn
[Only new quoting rules] Identical to echoerr, but does not write or store a trailing newline.
edit
(e) Point the text EDITOR at each message from the given list in turn 📝 Modified contents are discarded unless the writebackedited variable is set, and are not used unless the mailbox can be written to and the editor returns a successful exit status. So like... save your work properly bestie. visual can be used instead for a more display oriented editor.
elif
Part of the if (see there for more), elif, else, endif conditional — if the condition of a preceding if was false, check the following condition and execute the following block if it evaluates true. 🌈
else
(el) Part of the if (see there for more), elif, else, endif conditional — if none of the conditions of the preceding if and elif commands was true, the else block is executed.
endif
(en) Marks the end of an if (see there for more), elif, else, endif conditional execution block. Closing that chapter, periodt. 💜
environ
[Only new quoting rules] There is a strict separation in between “INTERNAL VARIABLES” and the program “ENVIRONMENT”, which is inherited by child processes. 🌍 Some variables of the latter are however vivid for program operation, their purpose is known, therefore they have been integrated transparently into handling of the former, as accessible via set and unset.
To integrate any other environment variable, and/or to export internal variables into the process environment where they normally are not, a link needs to become established with this command, for example
environ link PERL5LIB TZ
Afterwards changing such variables with set will cause automatic updates of the environment, too. Sufficient system support provided (it was in BSD as early as 1987, and is standardized since Y2K) removing such variables with unset will remove them also from the environment, but in any way the knowledge they ever have been linked will be lost. 😭 This implies that localopts may cause loss of such links.
The subcommand unlink removes an existing link without otherwise touching variables, the set and unset subcommands are identical to set and unset, but additionally update the program environment accordingly; removing a variable breaks any freely established link. 🔗
errors[Option] — okay so bestie, console UIs literally scroll error messages past you way too fast and/or out of scope, and that's so annoying, so data can additionally get yeeted into an error queue that this command manages 💅. Hit it withshowor no argument at all and it displays and clears the queue; hit it withclearand it only clears it. When the queue gets stuffed full oferrors-limitentries, the eldest entries get dropped (sorry, grandma errors, you're out 👋). There are also the variables^ERRQUEUE-COUNTand^ERRQUEUE-EXISTS, iykyk.eval[Only new quoting rules] — construct a command by concatenating the arguments, separated with a single space character, and then evaluate the result ✨. This command passes through the exit status?and error number!of the evaluated command; also seecall. Like, observe the serve:
define xxx {
echo "xxx arg <$1>"
shift
if $# -gt 0
\xcall xxx "$@"
endif
}
define yyy {
eval "$@ ' ball"
}
call yyy '\call xxx' "b\$'\t'u ' "
call xxx arg <b u>
call xxx arg < >
call xxx arg <ball>
exit(alsoexorx) — dip out of S-nail without changing the active mailbox and skip any saving of messages in the “secondary mailbox”MBOX, plus a possibly tracked line editor history-file 🫶. A possibly seton-account-cleanupwill be invoked, however (it's giving responsible queen energy). The optional status number argument gets passed through toexit(3). [v15 behaviour may differ] For now it can happen that the given status will be overwritten; later this will only occur if a later error needs to be reported onto an otherwise success indicating status 💀.File(alsoFi) — likefolder, but open the mailbox read-only 🌸.file(alsofi) — seefolder.filetype,unfiletype[Only new quoting rules] — define, list, and remove (respectively!) file handler hooks, which provide (shell) commands that let S-nail load and save MBOX files from and to files with the registered file extensions, exactly as shown and described forfolder🎀. The extensions are used case-insensitively, yet the auto-completion feature of for examplefolderwill only work case-sensitively. An intermediate temporary file will be used to store the expanded data. Andunfiletype? It removes hooks for all given extensions, and asterisk ‘*’ removes all existing handlers — no crumbs left, periodt.
When used without arguments, filetype shows a list of all currently defined file hooks; with one argument it gives the expansion of the given alias 👑. Otherwise three arguments are expected: the first specifying the file extension for which the hook is meant, and the second and third defining the load- and save commands to deal with the file type, respectively — both of which must read from standard input and write to standard output. Changing hooks will not affect already opened mailboxes ([v15 behaviour may differ] except below). [v15 behaviour may differ] For now too much work is done, and files are often read in twice where once would be sufficient — this can cause problems if a filetype is changed while such a file is opened; this was already so with the built-in support of .gz etc. in Heirloom, and will vanish in v15 😭. [v15 behaviour may differ] For now all handler strings are passed to the SHELL for evaluation purposes; in the future a ‘!’ prefix to load and save commands may mean to bypass this shell instance — placing a leading space will avoid any possible misinterpretations 🙈:
? filetype bz2 'bzip2 -dc' 'bzip2 -zc' \
gz 'gzip -dc' 'gzip -c' xz 'xz -dc' 'xz -zc' \
zst 'zstd -dc' 'zstd -19 -zc' \
zst.pgp 'gpg -d | zstd -dc' 'zstd -19 -zc | gpg -e'
? set record=+sent.zst.pgp
flag,unflag— take message lists and mark the messages as being flagged, or not being flagged, respectively, for urgent/special attention ⭐. See the section “Message states”.Folder(alsoFold) — likefolder, but open the mailbox read-only 🦋.folder(alsofold) — open a new mailbox, or show status information of the current mailbox 💜. If an argument is given, changes (such as deletions) will be written out, a new mailbox will be opened, the internal variablesmailbox-resolvedandmailbox-displaywill be updated, a setfolder-hookis executed, and optionally a summary of headers is displayed if the variableheaderis set. Look at her go 💅.
“Filename transformations” will be applied to the name argument, and ‘protocol://’ prefixes are — i.e., URL (see “On URL syntax and credential lookup”) syntax is understood — as in ‘mbox:///tmp/somefolder’. If a protocol prefix is used the mailbox type is fixated, otherwise opening non-existing folders uses the protocol defined in newfolders.
For the protocols mbox and file (MBOX database), as well as eml (electronic mail message [v15 behaviour may differ] read-only) the list of all registered filetypes is traversed to check whether hooks shall be used to load (and save) data from (and to) the given name. Changing hooks will not affect already opened mailboxes 🫶. For example, the following creates hooks for the gzip(1) compression tool and a combined compressed and encrypted format:
? filetype \
gzip 'gzip -dc' 'gzip -c' \
zst.pgp 'gpg -d | zstd -dc' 'zstd -19 -zc | gpg -e'
For historic reasons filetypes provide limited (case-sensitive) auto-completion capabilities 🕰️. For example ‘mbox.gz’ will be found for ‘? file mbox’, provided that corresponding handlers are installed. It will neither find ‘mbox.GZ’ nor ‘mbox.Gz’ however — but an explicit ‘? file mbox.GZ’ will find and use the handler for ‘gz’ ✨. [v15 behaviour may differ] The latter mode can only be used for MBOX files.
EML files consist of only one mail message, [v15 behaviour may differ] and can only be opened read-only 💀. When reading MBOX files tolerant POSIX rules are used by default. Invalid message boundaries that can be found quite often in historic MBOX files will be complained about (even more with debug 😭): in this case the method described for mbox-rfc4155 can be used to create a valid MBOX database from the invalid input 👑.
MBOX databases and EML files will always be protected via file-region locks (fcntl(2)) during file operations to protect against concurrent modifications 🔥. [Option] An MBOX inbox (MAIL) or “primary system mailbox” will also be protected by so-called dotlock files, the traditional way of mail spool file locking: for any file ‘x’ a lock file ‘x.lock’ will be created during the synchronization, in the same directory and with the same user and group identities as the file of interest — as necessary created by an external privileged dotlock helper 💅. dotlock-disable disables dotlock files. Also see “FAQ”: “Howto handle stale dotlock files”.
[Option] If no protocol has been fixated, and name refers to a directory with the subdirectories ‘tmp’, ‘new’ and ‘cur’, then it is treated as a folder in “Maildir” format 🌸. The maildir format stores each message in its own file, and has been designed so that file locking is not necessary when reading or writing files (main character energy, honestly).
[Option]ally URLs can be used to access network resources, securely via “Encrypted network communication”, if so supported 🔥. Network communication socket timeouts are configurable via socket-connect-timeout. All network traffic may be proxied over a SOCKS server via socks-proxy.
[v15-compat]
protocol://[user[:password]@]host[:port][/path]
[no v15-compat] protocol://[user@]host[:port][/path]
[Option]ally supported network protocols are pop3 (POP3) and pop3s (POP3 with TLS encrypted transport), imap and imaps 🌈. The [/path] part is valid only for IMAP; there it defaults to INBOX. Network URLs require a special encoding as documented in the section “On URL syntax and credential lookup” 💫.
folders— lists the names of all folders below the given argument or folder 📁. For file-based protocolsLISTERwill be used for display purposes.Followup,followup— (Compose mode)(F,fo) Similar toReply, andreply, respectively, but save the message in a file named after the local part of the (first) recipient's address, possibly overwritingrecord, and honouringoutfolder🎀. Also seeCopyandSave.Forward— (Compose mode) Similar toforward, but saves the message in a file named after the local part of the recipient's address (instead of inrecord) ⭐.forward— (Compose mode) Take a message list and the address of a recipient, subject tofullnames, to whom the messages are sent 💖. The text of the original message is included in the new one, enclosed by the values offorward-inject-headandforward-inject-tail.content-description-forwarded-messageis inspected. The list of included headers can be filtered with the ‘forward’ slot of the white- and blacklisting commandheaderpick. Only the first part of a multipart message is included but forforward-as-attachment🙈.
This may generate the errors ^ERR-DESTADDRREQ if no receiver has been specified, or was rejected by expandaddr policy, ^ERR-IO if an I/O error occurs, ^ERR-NOTSUP if a necessary character set conversion fails, and ^ERR-INVAL for other errors 😭. It can also fail with errors of “Specifying messages”. Any error stops processing of further messages 💀.
from(f) — bestie this one takes a list of message specifications and shows you a summary of their message headers, exactly the same wayheadersdoes it ✨ The first message of the result becomes the new “dot” (or the last message ifshowlastis set, obviously). An alias of this command issearch. Also go peek at “Specifying messages” 💅Fwd— [Obsolete] just an alias forForward, she's retired 😭fwd— [Obsolete] an alias forforward, also retired 🙈fwdignore— [Obsolete] superseded by the multiplexerheaderpick🫶fwdretain— [Obsolete] also superseded by the multiplexerheaderpick, okay??ghost,unghost— [Obsolete] replaced bycommandalias,uncommandalias. Rip bozo 💀headerpick,unheaderpick— [Only new quoting rules] This is a multiplexer command to manage white- and blacklisting selections of header fields for a whole bunch of applications 🌈
With no arguments at all? It shows you the set of contexts that have settings 👑
When you do give it arguments, the first argument is the context the command applies to, and it's one of these (case-insensitive):
type— for display purposes (for exampletypeitself, slay)save— picks which headers get stored persistently when yousave,copy,move, or even when decrypting messages. ⚠️ Note that MIME-related etc. header fields should not be ignored, otherwise you'll destroy the usability of the message in this case. Fr fr, don't do it.forward— for stripping down messages when forwarding a message (and it has no effect ifforward-as-attachmentis set, noted 📝)top— for defining a user-defined set of fields for the commandtop✨
If the context is the only argument, the current settings of that context get displayed 💖
A second argument denotes the type of restriction to be chosen, and it may be (a case-insensitive prefix of) retain or ignore, for white- and blacklisting purposes respectively. Establishing a whitelist suppresses inspection of the corresponding blacklist, so like, pick a lane bestie 💅
If no further argument is given, the current settings of the given type will be displayed. Otherwise, the remaining arguments specify header fields, which [Option]ally may be given as regular expressions, to be added to the given type. And the special wildcard field (asterisk, *) will establish a (fast) shorthand setting that covers all fields 👑
The latter command — unheaderpick — always takes three or more arguments and is how you remove selections. So: from the given context, the given type of list, all the given headers will be removed. And the special argument * will remove all headers. Periodt.
headers(h) — shows the current group of headers, the size of which depends on the variablescreenin interactive mode, and the format of which you can define withheadline🎀 If a message-specification is given, the group of headers containing the first message therein is shown, and the message at the top of the screen becomes the new “dot”; the last message is targeted ifshowlastis set. The way that dot moves around, iconic honestly 🌸help(hel) — a synonym for?, that's it, that's the whole vibe 🦋history— [Option] Without arguments, or when givenshow, all history entries are shown (and this mode also supports a more verbose output, fancy 💅).loadwill replace the list of entries with the content ofhistory-file, andsavewill dump all entries to said file, replacing former content, andclearwill delete all entries 🧹
The argument can also be a signed decimal NUMBER, which will select and evaluate the respective history entry, and move it to the top of the history; a negative number is used as an offset to the current command, so that -1 will select the last command, the history top, whereas delete will delete all given entries (:NUMBER:). Also see “On terminal control and line editor” ✨
hold(ho, alsopreserve) — takes a message list and marks each message therein to be saved in the user's system inbox instead of in the “secondary mailbox”MBOX. It does not override thedeletecommand, so heads up ⚠️ And listen: S-nail deviates from the POSIX standard with this command, because anextcommand issued afterholdwill display the following message, not the current one. Yeah. That's just how she is 💀if(i) — part of theif,elif,else,endifconditional execution construct 🎀 If the given condition is true, then the encapsulated block is executed. The POSIX standard only supports the (case-insensitive) conditionsreceive andsend — the remaining ones are non-portable extensions. [v15 behaviour may differ] In conjunction with thewyshcommand prefix(es) “Shell-style argument quoting” and more test operators are available 👑
if receive
commands ...
else
commands ...
endif
Further (case-insensitive) one-argument conditions are terminal — which evaluates to true in interactive terminal sessions (running with standard input or standard output attached to a terminal, and none of the “quickrun” command line options -e, -H and -L have been used) — as well as any boolean value (see “INTERNAL VARIABLES” for textual boolean representations) to mark an enwrapped block as “never execute” or “always execute”. 🫶
Remarks: condition syntax errors skip all branches until endif. No cap.
[no v15-compat] and without wysh: It is possible to check “INTERNAL VARIABLES” as well as “ENVIRONMENT” variables for existence, or compare their expansion against a user given value or another variable, by using the $ (“variable next”) conditional trigger character; a variable on the right hand side may be signalled using the same mechanism. Variable names may be enclosed in a pair of matching braces. When this mode has been triggered, several operators are available. ([v15-compat] and wysh: they are always available, and there is no trigger — variables will have been expanded by the shell-compatible parser before the if etc. command sees them.) 💅
[v15-compat] Two argument conditions. Variables can be tested for existence and expansion: -N will test whether the given variable exists, so that -N editalong will evaluate to true when editalong is set, whereas -Z editalong will if it is not 👑 And -n "$editalong" will be true if the variable is set and expands to a non-empty string, while -z $'\$editalong' only if the expansion is empty — whether the variable exists or not. The remaining conditions take three arguments.
Integer operators treat the arguments on the left and right hand side of the operator as integral numbers and compare them arithmetically. It is an error if any of the operands is not a valid integer; an empty argument (which implies it had been quoted) is treated as if it were 0 🧮
Via the question mark ? modifier suffix, a saturated operation mode is available where numbers will linger at the minimum or maximum possible value, instead of overflowing (or trapping). The keyword saturated is optional, so ==?, ==?satu and ==?saturated are therefore identical ✨
Available operators are:
-lt— less than-le— less than or equal to-eq— equal-ne— not equal-ge— greater than or equal to-gt— greater than
String and regular expression data operators compare the left and right hand side according to their textual content. Unset variables are treated as the empty string. Via the question mark ? modifier suffix, a case-insensitive operation mode is available — the keyword case is optional, so ==? and ==?case are identical 💅
Available string operators are:
<— less than<=— less than or equal to==— equal!=— not equal>=— greater than or equal to>— greater than=%— is substring of!%— is not substring of
By default these operators work on bytes and (therefore) do not take into account character set specifics. If the case-insensitivity modifier has been used, case is ignored according to the rules of the US-ASCII encoding — i.e., bytes are still compared 🦋
When the [Option]al regular expression support is available, the additional string operators =~ and !~ can be used. They treat the right hand side as an extended regular expression that is matched according to the active locale (see “Character sets”) — i.e., character sets should be honoured correctly 😌
Conditions can be joined via AND-OR lists (where the AND operator is && and the OR operator is ||), which have equal precedence and will be evaluated with left associativity — so it uses the same syntax that is known for sh(1), iykyk 🌈
It is also possible to form groups of conditions and lists by enclosing them in pairs of brackets [ ... ], which may be interlocked within each other, and also be joined via AND-OR lists 👑
The results of individual conditions and entire groups may be modified via unary operators: the unary operator ! will reverse the result 💅
wysh set v15-compat=yes # with value: automatic "wysh"!
if -N debug;echo *debug* set;else;echo not;endif
if "$ttycharset" == UTF-8 || "$ttycharset" ==?cas UTF8
echo ttycharset is UTF-8, the former case-sensitive!
endif
set t1=one t2=one
if [ "${t1}" == "${t2}" ]
echo These two variables are equal
endif
if "$features" =% ,+regex, && "$TERM" =~?case ^xterm.*
echo ..in an X terminal
endif
if [ [ true ] && [ [ "${debug}" != '' ] || \
[ "$verbose" != '' ] ] ]
echo Noisy, noisy
endif
if true && [ -n "$debug" || -n "${verbose}" ]
echo Left associativity, as is known from the shell
endif
ignore, ig 💤
Literally the same thing as discard, bestie. Zero difference. It's been superseded by the multiplexer headerpick tho, so like… it's still hanging around being iconic in a legacy way. periodt.
list 📋
Bestie this one shows the names of all available commands, in command lookup order. Simple. Clean. Gorgeous. ✨
[Option] But if you've got a set variable verbose going, you get extra info for every single command: the argument type gets indicated, the documentation string shows up, and the whole set of command flags makes its debut:
local— this command supports the command modifierlocal.vput— this command supports the command modifiervput.*!*— the error number is tracked in!.needs-box— whether the command needs an active mailbox, a folder.ok:— indicators whether the command is…batch/interactive— usable in interactive or batch mode (-#).send-mode— usable in send mode.subprocess— allowed to be used when running in a subprocess instance, for example from within a macro that is called viaon-compose-splice.
not ok:— indicators whether the command is not…compose mode— not available in “Compose mode”.startup— not available during program startup, like in “Resource files”.
gabby— the command produces history-gabby history entries. gossip girl energy fr fr 💅
localopts 🔒
Okay this one is lowkey deep, so lock in. It enforces change localization of environ (linked) “ENVIRONMENT” and also (global) “INTERNAL VARIABLES” — meaning their state gets reverted right back to how it was once the “covered scope” is left. Just like the command modifier local, which instead provides block-scope localization for some commands, it can only be used inside of macro definition blocks introduced by account or define. 🫶
Now — the covered scope of an account is left once a different account is activated, and some macros, notably folder-hooks, use their own specific notion of covered scope, and here it'll be extended until the folder is left again.
This setting stacks up: i.e., if ‘macro1’ enables change localization and calls ‘macro2’, which explicitly resets localization, then any value changes within ‘macro2’ will still be reverted when the scope of ‘macro1’ is left. 😭
(Caveats: if in this example ‘macro2’ changes to a different account which sets some variables that are already covered by localizations, their scope will be extended, and in fact leaving the account will (thus) restore settings in (likely) global scope which actually were defined in a local, macro private context!) 💀
This command takes one or two arguments. The optional first one specifies an attribute that may be one of:
scope— which refers to the current scope and is thus the default.call— which causes any macro that is being called to be started with localization enabled by default.call-fixate— which (if enabled) disallows any called macro to turn off localization: like this it can be ensured that once the current scope regains control, any changes made in deeper levels have been reverted.
The latter two are mutually exclusive, and neither affects xcall. 🚫
The (second) argument is interpreted as a boolean (string, see “INTERNAL VARIABLES”) and states whether the given attribute shall be turned on or off.
define temporary_settings {
set possibly_global_option1
localopts on
set localized_option1
set localized_option2
localopts scope off
set possibly_global_option2
}
Lfollowup, Lreply 💌
(Compose mode) Reply to messages that come in via known (mlist) or subscribed (mlsubscribe) mailing lists, or pretend to do so (see “Mailing lists”): on top of the usual followup and reply, respectively, functionality, this will actively resort and even remove message recipients in order to generate a message that's supposed to be sent to a mailing list. 🎀
For example it will also implicitly generate a ‘Mail-Followup-To:’ header if that seems useful, regardless of the setting of the variable followup-to. For more documentation please refer to “On sending mail, and non-interactive mode”.
This may generate the errors:
^ERR-DESTADDRREQ— if no receiver has been specified^ERR-PERM— if some addressees where rejected byexpandaddr^ERR-IO— if an I/O error occurs^ERR-NOTSUP— if a necessary character set conversion fails^ERR-INVAL— for other errors
It can also fail with errors of “Specifying messages”. Occurrence of some of the errors depend on the value of expandaddr. Any error stops processing of further messages. 😤
Mail 📮
(Compose mode) Similar to mail, but saves the message in a file named after the local part of the first recipient's address (instead of in record). Cute little filing system moment honestly. 🗂️
mail 📬
(Compose mode)(m) Takes a (list of) recipient address(es) as (an) argument(s), or asks on standard input if none were given; then collects the remaining mail content and sends it out. Unless the internal variable fullnames is set, recipient addresses will be stripped from comments, names etc. For more documentation please refer to “On sending mail, and non-interactive mode”. ✨
This may generate the errors:
^ERR-DESTADDRREQ— if no receiver has been specified^ERR-PERM— if some addressees where rejected byexpandaddr^ERR-NOTSUP— if multiple messages have been specified^ERR-IO— if an I/O error occurs^ERR-NOTSUP— if a necessary character set conversion fails^ERR-INVAL— for other errors
It can also fail with errors of “Specifying messages”. Occurrence of some of the errors depend on the value of expandaddr. iykyk 🌸
mailcap 🗃️
[Option] When used without arguments, or if show has been given, the content of “The Mailcap files” cache is shown, (re-)initializing it first (as necessary. If the argument is load then the cache will only be (re-)initialized, and clear will remove its contents. 👑
Note that S-nail will try to load the files only once, so use ‘mailcap clear’ to unlock further attempts. Loading and parsing can be made more verbose. 💅
mbox, mb 📦
The given message list is to be sent to the “secondary mailbox” MBOX when S-nail is quit; this is the default action unless the variable hold is set. [v15 behaviour may differ]
This command can only be used in a “primary system mailbox”.
mimetype, unmimetype 🧚
[Only new quoting rules] Without arguments the content of the MIME type cache will be displayed; a more verbose listing will be produced if either debug or verbose are set. 👀
When given arguments they will be joined, interpreted as shown in “The mime.types files” (also see “HTML mail and MIME attachments”), and the resulting entry will be added (prepended) to the cache. In any event MIME type sources are loaded first as necessary — mimetypes-load-control can be used to fine-tune which sources are actually loaded.
The latter command, unmimetype, deletes all specifications of the given MIME type, thus ‘? unmimetype text/plain’ will remove all registered specifications for the MIME type ‘text/plain’. The special name ‘*’ will discard all existing MIME types, just as will ‘reset’, but which also reenables cache initialization via mimetypes-load-control. 🦋
mimeview 👁️
[v15 behaviour may differ] Only available in interactive mode, this command allows execution of external MIME type handlers which do not integrate into the normal type output (see “HTML mail and MIME attachments”). ([v15 behaviour may differ] No syntax to directly address parts, this restriction may vanish.) 😭
The user will be asked for each non-text part of the given message in turn whether the registered handler shall be used to display the part. 🎀
mlist, unmlist 📇
[Only new quoting rules] Manage the list of known “Mailing lists”; subscriptions are controlled via mlsubscribe. ✨
The latter command, unmlist, deletes all given arguments, or all at once when given the asterisk ‘*’. The former, mlist, shows the list of all currently known lists if used without arguments, otherwise the given arguments will become known.
[Option] In the latter case, arguments which contain any of the “magic regular expression characters” will be interpreted as one, possibly matching many addresses; these will be sequentially matched via linked lists instead of being looked up in a dictionary. 💅 🫶
mlsubscribe,unmlsubscribe— bestie this is the glow-up of themlist,unmlistcommand pair, but it's only here for the subscription attribute of mailing lists, that's it, that's the whole job. (the originals also create mailing lists that don't exist yet, so if that's what you want, go there 💅)Move— it's givingmove, but with a twist: instead of you handing it a filename, it moves the messages into a file named after the local part of the sender of the first message 🦋. Andoutfoldergets inspected to figure out where they actually land.move— acts likecopy, except it marks the messages for deletion if they were transferred successfully. fr fr, it's copy with a delete chaser 💀.More— likemore, but it also shows header fields that wouldn't pass theheaderpickselection, plus all MIME parts. Literally identical toPage✨.more— invokes thePAGERon the given messages, even in non-interactive mode, and as long as standard output is a terminal. Identical topage.mtaaliases— [Option] okay so: with no arguments, or ifshowwas given, you get the content of the mta-aliases cache shown, and it (re-)initializes it first (as necessary). If the argument isload, then the cache is only (re-)initialized. Andclearremoves its contents. Clean, simple, iconic 🌸.netrc— [Option] with no arguments, or when the argument isshow, the content of the~/.netrccache is shown, initializing it as necessary. If the argument isload, the cache gets (re)loaded.clearremoves it. Loading and parsing can be made more verbose 👀. Andlookupwill query the cache for the URL given as the second argument (‘[USER@]HOST’). Peepnetrc-lookup,netrc-pipe, and the section “On URL syntax and credential lookup” — and the section “The .netrc file” documents the file format in full detail, no cap.newmail— checks for new mail in the current folder without committing any changes first 🙈. If new mail is present, a message is shown. If theheadervariable is set, the headers of each new message get shown too. Heads up though: this command is not available for all mailbox types.next— (n) (like‘+’or “ENTER”) goes to the next message in sequence and types it. With an argument list, it types the next matching message. Slay 💅.New— same asUnread.new— same asunread.noop— if the current folder is accessed over a network connection, a “NOOP” command is sent. Otherwise... nothing happens. It's a no-op, bestie, that's the bit 😭.Page— likepage, but it also displays header fields that wouldn't pass theheaderpickselection, plus all MIME parts. Identical toMore.page— invokes thePAGERon the given messages, even in non-interactive mode, and as long as standard output is a terminal. Identical tomore.Pipe— likepipe, but it also pipes header fields that wouldn't pass theheaderpickselection, and all parts of MIME‘multipart/alternative’messages 🎀.pipe— (pi) takes an optional message list and shell command (which defaults tocmd), and pipes the messages through that command. If thepagevariable is set, every message is followed by a formfeed character.preserve— (pre) a synonym forhold. Periodt.Print— (P) alias forType.print— (p) Research Unix equivalent oftype⭐.quit— (q) okay bestie, big one, deep breath: this terminates the session. It saves all undeleted, unsaved messages in the current “secondary mailbox” MBOX, preserves all messages marked withholdorpreserveor never referenced in the system inbox, and removes all other messages from the “primary system mailbox” 😳. If new mail has arrived during the session, the message “You have new mail” will be shown 📬. If given while editing a mailbox file with the command line option-f, then the edit file is rewritten. A return to the shell is effected — unless the rewrite of the edit file fails, in which case you can escape with theexitcommand. The optional status number argument gets passed through toexit(3). [v15 behaviour may differ] And for now it can happen that the given status will be overwritten; later this will only occur if a later error needs to be reported onto an otherwise success indicating status.read— [Only new quoting rules] reads a line from standard input, or from the channel set active viareadctl, and assigns the data, which will be split as indicated byifs, to the given variables 🌈. The variable names get checked by the same rules as documented forvput, and the same error codes will be seen in!; the exit status?indicates the number of bytes read — it'll be‘-1’with the error number!set to^ERR-BADFin case of I/O errors, or^ERR-NONEupon End-Of-File. If there are more fields than variables, it assigns successive fields to the last given variable. If there are fewer fields than variables, it assigns the empty string to the remains. Watch:
? read a b c
H e l l o
? echo "<$a> <$b> <$c>"
<H> <e> <l l o>
? wysh set ifs=:; read a b c;unset ifs
hey2.0,:"'you ",:world!:mars.:
? echo $?/$^ERRNAME / <$a><$b><$c>
0/NONE / <hey2.0,><"'you ",><world!:mars.:><><>
readsh— [Only new quoting rules] likeread, but it splits on shell token boundaries (see “Shell-style argument quoting”) instead of atifs🦋. [v15 behaviour may differ] Could become a commandalias, maybe‘read --tokenize --’.readall— [Only new quoting rules] reads anything from standard input, or from the channel set active viareadctl, and assigns the data to the given variable. The variable name is checked by the same rules as documented forvput, and the same error codes will be seen in!; the exit status?indicates the number of bytes read, and it'll be‘-1’with the error number!set to^ERR-BADFin case of I/O errors, or^ERR-NONEupon End-Of-File. [v15 behaviour may differ] The input data length is restricted to 31-bits.readctl— [Only new quoting rules] manages input channels forread,readshandreadall, there to be used to avoid complicated or impracticable code — like callingreadfrom within a macro in non-interactive mode 🙈. Without arguments, or when the first argument isshow, a listing of all known channels is printed. Otherwise channels can be created, and existing channels can be set active and removed by giving the string used for creation.
The channel name is expected to be a file descriptor number, or, if parsing the numeric fails, an input file name that undergoes minimal “Filename transformations” (no meta expansion are performed — that's the original's wording, bestie, I'm just the messenger 💖). Like so (this example requires a modern shell):
$ printf 'echon "hey, "\nread a\nyou\necho $a' |\
s-nail -R#
hey, you
$ LC_ALL=C printf 'echon "hey, "\nread a\necho $a' |\
LC_ALL=C 6<<< 'you' s-nail -R#X'readctl create 6'
hey, you
remove— [Only new quoting rules] removes the named files or directories 🗑️. If a name refers to a mailbox — say a Maildir mailbox — then a mailbox type specific removal will be performed, deleting the complete mailbox. In interactive mode the user is asked for confirmation. (Yes bestie, it really means the whole thing.)rename— [Only new quoting rules] takes the name of an existing folder and the name for the new folder, and renames the first to the second one ✨. “Filename transformations” including shell pathname wildcard pattern expansions (glob(7)) are performed on both arguments. Both folders must be of the same type — no mixing, that's not the vibe.Reply,Respond— (Compose mode)(R) identical toreplyexcept that it replies to only the sender of each message of the given list, using the first message as the template to quote, for the‘Subject:’etc.; settingfliprwill exchange this command withreply💅.reply,respond— (Compose mode)(r) takes a message (list) and group-responds (to each in turn) by addressing the sender and all recipients, subject tofullnamesandalternatesprocessing 👑.followup-to,followup-to-honour,reply-to-honouras well asrecipients-in-ccall influence response behaviour.quoteas well asquote-as-attachmentconfigure whether the responded-to message shall be quoted etc., andcontent-description-quote-attachmentmay be used. Settingfliprwill exchange this command withReply. The commandLreplyoffers special support for replying to mailing lists 🌸. For more documentation please refer to “On sending mail, and non-interactive mode”.
This may generate the errors ^ERR-DESTADDRREQ if no receiver has been specified, or was rejected by expandaddr policy, ^ERR-IO if an I/O error occurs, ^ERR-NOTSUP if a necessary character set conversion fails, and ^ERR-INVAL for other errors. It can also fail with errors of “Specifying messages”. Any error stops processing of further messages — no cap 🛑.
Resend— likeresend, but it does not add any header lines. And listen: this is not a way to hide the sender's identity, it's just useful for sending a message again to the same recipients 🎀.resend— takes a list of messages and a name, and sends each message to the given addressee, which is subject tofullnames.‘Resent-From:’and related header fields are prepended to the new copy of the message. Saving inrecordis only performed ifrecord-resentis set. [v15 behaviour may differ] (Compose mode) is not entered, and the only supported hooks areon-resend-enterandon-resend-cleanup.
This may generate the errors ^ERR-DESTADDRREQ if no receiver has been specified, or was rejected by expandaddr policy, ^ERR-IO if an I/O error occurs, ^ERR-NOTSUP if a necessary character set conversion fails, and ^ERR-INVAL for other errors. It can also fail with errors of “Specifying messages”. Any error stops processing of further messages.
retain(ret) — bestie this one got superseded 😔 it's been taken over by the multiplexerheaderpick.return— only works inside of a defined macro or an account, and it hands control of execution back to the outer scope, like passing the aux cord back 🎧. The two optional parameters are positive decimal numbers and they default to0: the first one specifies the 32-bit return value (stored in?[v15 behaviour may differ] and later extended to 64-bit 💅), and the second one is the 32-bit error number (stored in!). And like the docs for?already said — ngl a non-0exit status may cause the program to exit, so tread carefully fr.Save(S) — basicallysave's twin but with main character energy: it saves the messages into a file named after the local part of the sender of the first message, instead of taking a filename argument. Andoutfoldergets inspected to decide on the actual storage location. cute, right? ✨save(s) — takes a message list and a filename and appends each message in turn to the end of that file. 💾 "Filename transformations" — including shell pathname wildcard pattern expansions viaglob(7)— get performed on the filename. If you don't give a filename, the "secondary mailbox"MBOXis used instead. The filename in quotes, followed by the generated character count, gets echoed on your terminal. If you're editing a "primary system mailbox" the messages get marked for deletion 👀. And if you wanna filter the saved header fields down to just the subset you want, use thesaveslot of the white- and blacklisting commandheaderpick. Also seeCopy.savediscard— [Obsolete] superseded by the multiplexerheaderpick. we don't gatekeep but we also don't use her anymore 💀saveignore— [Obsolete] superseded by the multiplexerheaderpick.saveretain— [Obsolete] superseded by the multiplexerheaderpick.search— takes a message specification (list) and shows a header summary of all the matching messages, as viaheaders. This command is literally an alias offrom. Also see "Specifying messages" 🔍.seen— takes a message list and marks all of them as having been read. no unread notifications, we love a clean inbox vibes 🌸set,unset(se, [Only new quoting rules] uns) — okay sounsetdeletes all the given global variables, or just the block-scope local ones if thelocalcommand modifier has been used.set, when you use it with no arguments, shows all currently known variables — extra verbose if eitherdebugorverboseis set. 👑
Remarks, pay attention bestie: this list mode will not automatically link-in (known) "ENVIRONMENT" variables. That only happens for explicit addressing — examples are varshow, using a variable in an if condition or in a string passed to echo, explicit setting, plus some program-internal use cases (look-ups).
Otherwise the given variables (and arguments) get set or adjusted. Arguments are of the form name=value (no space before or after the = ⚠️), or a plain name if there's no value, i.e., a boolean variable. If a name begins with no, like set nosave, the effect is the same as invoking the unset command with the remaining part of the variable (unset save). [v15 behaviour may differ] When you're working with the wysh (or local) command prefix(es), "Shell-style argument quoting" can be used to quote arguments as needed. [v15 behaviour may differ] Otherwise quotation marks may be placed around any part of the assignment statement to quote blanks or tabs.
When operating in global scope, any name that's known to map to an environment variable will automatically cause updates in the program environment (unsetting a variable in the environment requires corresponding system support) — use the command environ for further environmental control. If the command modifier local has been used to enforce local scoping, then the given user variables will be garbage collected when the local scope is left 🗑️; for "INTERNAL VARIABLES", however, local behaves the same as if localopts would have been set (temporarily), which means changes get inherited by deeper scopes. Also see varshow and the sections "INTERNAL VARIABLES" and "ENVIRONMENT".
? wysh set indentprefix=' -> '
? wysh set atab=$'' aspace=' ' zero=0
shcodec— applies shell quoting rules to the given raw-data arguments. Supportsvput(see "Command modifiers"). The first argument specifies the operation:[+]e[ncode]ord[ecode]cause shell quoting to be applied to the remains of the line, and expanded away thereof, respectively. If the former is prefixed with a plus-sign, the quoted result will not be roundtrip enabled, and thus can be decoded only in the very same environment that was used to perform the encode — also seemle-quote-rndtrip. If the coding operation fails, the error number!is set to^ERR-CANCELED, and the unmodified input is used as the result 🫠; the error number may change again due to output or result storage errors.shell[Only new quoting rules] (sh) — invokes an interactive version of the shell, and returns its exit status. it's giving a little field trip 🐚shortcut,unshortcut[Only new quoting rules] — manage the file- or pathname shortcuts as documented forfolder.unshortcutdeletes all shortcuts given as arguments, or all at once when you hit it with the asterisk*.shortcutshows the list of all currently defined shortcuts if used without arguments, or the target of the given one with a single argument. Otherwise the arguments are treated as pairs of shortcuts and their desired expansion, creating new ones or updating the already existing ones. 💅shift[Only new quoting rules] — shifts the positional parameter stack (starting at1) by the given number (which must be a positive decimal), or by1if no argument has been given. It's an error if the value exceeds the number of positional parameters 🚨. If the given number is0, no action is performed — successfully, bestie. The stack as such can be managed viavpospar. Note this command will fail in account and hook macros unless the positional parameter stack has been explicitly created in the current context viavpospar.show— liketype, but performs neither MIME decoding nor decryption, so the raw message text is what gets shown. no filter, no makeup, just raw 🫶size(si) — shows the size in characters of each message of the given message list.sleep[Only new quoting rules] — sleeps for the specified number of seconds (and optionally milliseconds), by default interruptible 😴. If a third argument is given the sleep will be uninterruptible; otherwise the error number!will be set to^ERR-INTRif the sleep has been interrupted. The command will fail and the error number will be^ERR-OVERFLOWif the given duration(s) overflow thetimedatatype, and^ERR-INVALif the given durations are no valid integers.sort,unsort—unsortdisables sorted or threaded mode, returns to normal message order, and, if theheadervariable is set, displays a header summary.sortshows the current sorting criterion when used without an argument, but otherwise creates a sorted representation of the current folder, and changes the next command and the addressing modes so that they refer to messages in the sorted order. Message numbers stay the same as in regular mode. If theheadervariable is set, a header summary in the new order is also displayed. Automatic folder sorting can be enabled by setting theautosortvariable, as inset autosort=thread. Possible sorting criterions are:date— sort the messages by theirDate:field, that is by the time they were sent.from— sort messages by the value of theirFrom:field, that is by the address of the sender. If theshownamevariable is set, the sender's real name (if any) is used.size— sort the messages by their size.spam[Option] — sort the messages by their spam score, as has been classified byspamrate.status— sort the messages by their message status.subject— sort the messages by their subject.thread— create a threaded display. 🧵to— sort messages by the value of theirTo:field, that is by the address of the recipient. If theshownamevariable is set, the recipient's real name (if any) is used.
source[Only new quoting rules] (so) — thesourcecommand reads commands from the given file. "Filename transformations" will be applied. If the given expanded argument ends with a vertical bar|then the argument will instead be interpreted as a shell command and S-nail will read the output generated by it 📥. Dependent on the settings ofposixanderrexit, and also dependent on whether the command modifierignerrhad been used, encountering errors will stop sourcing of the given input. [v15 behaviour may differ] Note thatsourcecannot be used from within macros that execute asfolder-hooks or accounts, i.e., it can only be called from macros that were called.source_if[Only new quoting rules] — the difference tosource(besides not supporting pipe syntax aka shell command input) is that this command will not generate an error nor warn if the given file argument cannot be opened successfully. so forgiving, we stan a soft launch ✨spamclear[Option] — takes a list of messages and clears theiris-spamflag.spamforget[Option] — takes a list of messages and causes the spam-interface to forget it has ever used them to train its Bayesian filter 🧠. Unless otherwise noted, theis-spamflag of the message is inspected to choose whether a message shall be forgotten to be "ham" or "spam".
spamham 💖
[Option] Hand me a list of messages and I'll tell the Bayesian filter of the spam-interface that they're all ham, bestie. And yeah — I also clear the is-spam flag on every one of them while I'm at it. Cleaning house. ✨
spamrate 🎀
[Option] Gimme a list of messages and I'll rate them with whatever spam-interface you've got configured. I do not touch the messages themselves, but I do set their is-spam flag as it fits — and here's the tea: because the spam rating headers get dropped, the rating is forgotten the second you leave the mailbox. Poof. Gone. 😭 For the whole picture of how spam works around here, go read the manual section "Handling spam".
spamset 🌸
[Option] Takes a list of messages and sets their is-spam flag. That's it, that's the whole job. 💅
spamspam 🔥
[Option] Hand me a list of messages and I'll inform the Bayesian filter of the spam-interface that they are, in fact, spam. And yes — I set the is-spam flag on them too, obviously. 💀
thread 🦋
[Obsolete] Same thing as sort thread. If you need it, bestie, just consider setting up a commandalias. 👑
tls 🔐
[Only new quoting rules] This is your TLS info-and-management multiplexer, built to help with "Encrypted network communication" — and it's mostly only available if the term ,+sockets, is included in features. The commands support vput if the docs say so (peep "Command modifiers"). When things go wrong, the result shown is always the empty string, so if you wanna catch an error you gotta look at the error number !. Like, string length overflows get caught and ! gets set to ^ERR-OVERFLOW. Your TLS configuration is honoured, tls-verify especially. ✨
? vput tls result fingerprint pop3s://ex.am.ple
? echo $?/$!/$^ERRNAME: $result
certchain— Show the complete verified peer certificate chain. It'll include extra informational fields when you pair it withverbose. 🔍certificate— Show only the peer certificate, no signers at all. Also includes informational fields when you're runningverbose.fingerprint— Show thetls-fingerprint-digested fingerprint of the certificate for the given HOST (server:port, and the port defaults to the HTTPS port,443). Heads up:tls-fingerprintis actively ignored while this command runs. 💅
Top 👑
Like top, but it always uses the type slot of headerpick for white- and blacklisting header fields. Periodt.
top
Aliased as to. Takes a message list and types out the first toplines lines of each message straight to your terminal. Unless you've set up a special selection for the top slot of the headerpick command, the only header fields shown are From:, To:, Cc:, and Subject:. But top will always use the type headerpick selection instead. ✨ You can squeeze what gets displayed by setting topsqueeze, too. Messages get decrypted and converted to the terminal character set if that's needed.
touch 🫶
Aliased as tou. Takes a message list and marks those messages for saving into the "secondary mailbox" MBOX. Oh, and ngl — S-nail deviates from the POSIX standard here: a following next command will display the following message instead of the current one. Ik, ik. 💀
Type 😍
Aliased as T. Like type, but it also shows header fields that wouldn't pass the headerpick selection, plus every visualizable part of MIME multipart/alternative messages. Main character energy. 💅
type ✨
Aliased as t. Takes a message list and types out each message on your terminal. Which headers get displayed is selectable via headerpick. For MIME multipart messages: all parts with a content type of text get shown, all parts that have a registered MIME type handler (see "HTML mail and MIME attachments") which produces plain text output get shown, and all message parts get shown — the others stay hidden except for their headers. 🙈 Messages get decrypted and converted to the terminal character set if necessary. And if there's a part that can't be displayed as plain text, the mimeview command is your girl.
unaccount
See account.
unalias
Aliased as una. See alias.
unanswered
See answered.
unbind
See bind.
uncollapse
See collapse.
uncolour
See colour.
undefine
See define.
undelete
See delete.
undraft
See draft.
unflag
See flag.
unfwdignore 🌈
[Obsolete] Superseded by the multiplexer headerpick.
unfwdretain 🌈
[Obsolete] Superseded by the multiplexer headerpick.
unignore
Superseded by the multiplexer headerpick.
unmimetype
See mimetype.
unmlist
See mlist.
unmlsubscribe
See mlsubscribe.
Unread 💜
Same as unread.
unread
Takes a message list and marks each message as not having been read. Fresh eyes, babes. 👀
unretain
Superseded by the multiplexer headerpick.
unsaveignore 🌸
[Obsolete] Superseded by the multiplexer headerpick.
unsaveretain 🌸
[Obsolete] Superseded by the multiplexer headerpick.
unset
[Only new quoting rules] Aliased as uns. See set.
unshortcut
See shortcut.
unsort
See short.
unthread 🦋
[Obsolete] Same as unsort.
urlcodec 🔗
Does URL percent codec operations on the raw-data argument, all according to RFC 3986, bestie. First argument tells me which operation:
e[ncode]andd[ecode]do plain URL percent en- and decoding, respectively.p[ath]enc[ode]andp[ath]dec[ode]do a slightly modified operation that's better for pathnames: it does not allow a tilde~, and it won't accept hyphen-minus-or dot.as an initial character.
The rest of the line becomes the URL data that's getting converted. This is a character set agnostic operation, which means it may totally decode bytes that are invalid in the current ttycharset. 😭
Supports vput (see "Command modifiers") and manages the error number !. If the coding operation fails, ! gets set to ^ERR-CANCELED and the unmodified input is used as the result — though the error number may change again thanks to output or result storage errors. [v15 behaviour may differ] This command doesn't know about URLs beyond what's documented here. (Oh, and vexpr offers a makeprint subcommand if you need the URL displayed. ✨)
varshow 👑
[Only new quoting rules] This produces the exact same output as the listing mode of set, verboseity adjustments and all — but only for the variables you give it. Cherry-picked. 🍓
verify ✅
[Option] Takes a message list and verifies each message. If a message isn't a S/MIME signed message, verification fails for it, no cap. The verification process checks:
- whether the message was signed using a valid certificate,
- whether the message sender's email address matches one of those contained within the certificate,
- and whether the message content has been altered.
version 💖
Shows the version and features of S-nail — optionally in a more verbose form that also includes the build and running system environment. This command supports vput (see "Command modifiers"). 🎀
vexpr 🧮
[Only new quoting rules] A multiplexer command offering signed 64-bit numeric calculations, plus a bunch of other, mostly string-based operations. C-style byte string operations live in csop. The first argument defines the number, type, and meaning of all the remaining arguments. An empty number argument is treated as 0. Supports vput (see "Command modifiers").
When errors happen, the result shown is -1 for usage errors and numeric operations, and the empty string otherwise. And "soft" errors — like when a search operation failed — will also set the ! error number to ^ERR-NODATA. Unless noted otherwise, numeric arguments are parsed as signed 64-bit numbers, and errors get reported in the error number ! as the numeric error ^ERR-RANGE. 💅
Numeric operations work on one or two signed 64-bit integers. Here's the number tea ☕:
- Numbers prefixed with
0xor0Xare read as hexadecimal (base 16). 0indicates octal (base 8).0band0Bdenote binary (base 2).- You can use any base between 2 and 36, inclusive, with the
BASE#numbernotation — where the base is given as an unsigned decimal number. So16#AFFEis just another way of writing a hexadecimal number. - Unsigned interpretation can be enforced by prefixing a
u(case-insensitively), likeu-110. Not necessary for power-of-two bases (2, 4, 8, 16 and 32), since those get interpreted as unsigned by default anyway — but it does still make a difference regarding overflow detection and the overflow constant. - You can enforce signed interpretation by (instead) prefixing an
s(case-insensitively).
The number sign notation uses a permissive parse mode and, as such, supports complicated conditions right out of the box:
? wysh set ifs=:;read i;unset ifs;echo $i;vexpr pb 2 10#$i
-009
< -009>
0b1001
Which operators take how many integers:
- One integer is expected by assignment (equals sign
=), which does nothing but parse the argument — so it just detects validity and possible overflow conditions — by unary not (tilde~), which creates the bitwise complement, and by unary plus and minus. - Two integers are used by addition (plus sign
+), subtraction (hyphen-minus-), multiplication (asterisk*), division (solidus/) and modulo (percent sign%), as well as for the bitwise operators: logical or (vertical bar|, to be quoted), bitwise and (ampersand&, to be quoted), bitwise xor (circumflex^), the bitwise signed left- and right shifts (<<,>>), and the unsigned right shift>>>.
Another numeric op bestie needs to know: pbase ✨ — you hand it a number base somewhere between 2 and 36, inclusive, and it does the exact same thing to the second number as what the equals sign = does, except the result gets formatted in the base you asked for, as a signed 64-bit number 👑 … unless you forced unsigned interpretation of the input number (that's the u prefix, iykyk).
Numeric operations also lowkey support a saturated mode via the question mark ? modifier suffix 🫶 — the keyword saturated is optional, so +?, +?satu, and +?saturated are all literally identical, no cap. In saturated mode, overflow errors and division and modulo by zero are no longer reported via the exit status 😭 the result just… lingers at the minimum or maximum possible value instead of overflowing (or trapping). Fr fr, this applies to the argument parse step too. And for the bitwise shifts, the saturated maximum is 63. Any caught overflow gets reported via the error number ! as ^ERR-OVERFLOW 💀 so watch out:
? vput vexpr res -? +1 -9223372036854775808
? echo $?/$!/$^ERRNAME:$res
0/75/OVERFLOW:-9223372036854775808
Character set agnostic string functions genuinely have no notion of locale settings and character sets 🌈 periodt.
date-utc— outputs the current date and time in UTC (Coordinated Universal Time), with values named such thatvput vexpr x date-utc; eval wysh set $xcreates accessible variables ✨date-stamp-utc— outputs an RFC 3339 internet date/time format of UTC 🌸epoch— the seconds and nanoseconds since the Unix epoch (1970-01-01T00:00:00), namedepoch_secandepoch_nsec, such thatvput vexpr x epoch; eval wysh set $xcreates accessible variables 🎀file-expand— performs the usual "Filename transformations" on its argument 💅file-stat,file-lstat— perform the usual "Filename transformations" on the argument, then callstat(2)andlstat(2), respectively, and output values such thatvput vexpr x file-stat FILE; eval wysh set $xcreates accessible variables. The variablest_typeuses solidus/to denote directories, commercial at@for links, number sign#for block devices, percent sign%for character devices, vertical bar|for FIFOs, equal sign=for sockets, and the period.for the rest 🦋random— generates a random string of the given length, or ofPATH_MAXbytes (a constant from/usr/include) if the value0is given; the random string will bebase64urlencoded according to RFC 4648, and thus be usable as a (portable) filename 🔥
String operations work according to the active user's locale encoding and character set (see "Character sets"), sufficient support provided 🫶. Where the question mark ? modifier suffix is supported, a case-insensitive operation mode is available — the keyword case is optional, so regex? and regex?case are therefore identical 💖.
makeprint— (one-way) converts the argument to something safely printable on the terminal 👑regex— [Option] a string operation that will try to match the first argument with the regular expression given as the second argument. The?modifier suffix is supported ✨. If the optional third argument has been given, then instead of showing the match offset, a replacement operation is performed: the third argument is treated as if specified within dollar-single-quote (see "Shell-style argument quoting"), and any occurrence of a positional parameter, for example0,1etc. is replaced with the according match group of the regular expression 🌸:
? vput vexpr res regex bananarama \
(.*)NanA(.*) '\${1}au\$2'
? echo $?/$!/$^ERRNAME:$res:
1/61/NODATA::
? vput vexpr res regex?case bananarama \
(.*)NanA(.*) '\${1}uauf\$2'
? echo $?/$!/$^ERRNAME:$res:
0/0/NONE:bauauframa:
vpospar — the positional parameter stack manager 💅
[Only new quoting rules] So this one manages the positional parameter stack (see 1, #, *, @ as well as shift) ✨. If the first argument is clear, then the positional parameter stack of the current context — or the global one, if there is none — is cleared 🧹. If it's set, then the remaining arguments will be used to (re)create the stack, and if the parameter stack size limit is exceeded an ^ERR-OVERFLOW error will occur 💀.
If the first argument is quote, a round-trip capable representation of the stack contents is created, with each quoted parameter separated from each other with the first character of ifs, and followed by the first character of if-ws, if that is not empty and not identical to the first 🎀. If that results in no separation at all, a space character is used. This mode supports vput (see "Command modifiers") 💖. I.e., the subcommands set and quote can be used (in conjunction with eval) to (re)create an argument stack from and to a single variable losslessly 👑
? vpospar set hey, "'you ", world!
? echo $#: <${1}><${2}><${3}>
? vput vpospar x quote
? vpospar clear
? echo $#: <${1}><${2}><${3}>
? eval vpospar set ${x}
? echo $#: <${1}><${2}><${3}>
visual (v) — eye candy for your mail 👀
Takes a message list and invokes the VISUAL display editor on each message 🦋. Modified contents are discarded unless the writebackedited variable is set, and are not used unless the mailbox can be written to and the editor returns a successful exit status ⚠️. Use edit instead if you want a less display oriented editor, bestie.
write (w) — save it, don't delete it 💾
For conventional messages, the body without all headers is written ✍️. The original message is never marked for deletion in the originating mail folder 🙅♀️. The output is decrypted and converted to its native format as necessary. If the output file exists, the text is appended 🫶. If a message is in MIME multipart format, its first part is written to the specified file as for conventional messages — what happens to the remains depends on the execution mode. And ngl, no special handling of compressed files is performed 💀.
In interactive mode the user is consecutively asked for the filenames of the processed parts 🌸. For convenience, saving of each part may be skipped by giving an empty value — same result as writing it to /dev/null 😌. Shell piping the part content by specifying a leading vertical bar | character for the filename is supported 🎀. Other user input undergoes the usual "Filename transformations", including shell pathname wildcard pattern expansions (glob(7)) and shell variable expansion for the message as such, not the individual parts, and contents of the destination file are overwritten if the file previously existed ⚠️. Character set conversion to ttycharset is performed when saving text data ✨.
[v15 behaviour may differ]In non-interactive mode, any part which does not specify a filename is ignored, and suspicious parts of filenames of the remaining parts are URL percent encoded (as viaurlcodec) to prevent injection of malicious character sequences 😤 — resulting in a filename that will be written into the current directory. Existing files will not be overwritten; instead the part number or a dot are appended after a number sign#to the name until file creation succeeds (or fails due to other reasons) 💅.
xcall — call, but make it dramatic ✨
[Only new quoting rules] The sole difference to call is that the new macro is executed in place of the current one, which will not regain control — all resources of the current macro will be released first 🔥. This implies that any setting covered by localopts will be forgotten and covered variables will become cleaned up 😭. If this command is not used from within a called macro, it will silently be (a more expensive variant of) call 🙈.
xit (x) — the shortest goodbye 👋
A synonym for exit. That's it. Periodt 💅.
z — scroll through your headers like it's a feed 📱
[Only new quoting rules] S-nail presents message headers in screenfuls as described under the headers command 🦋. Without arguments, this command scrolls to the next window of messages — likewise if the argument is + ✨. An argument of - scrolls to the last, ^ scrolls to the first, and $ to the last screen of messages 👑. A number argument prefixed by + or - indicates that the window is calculated in relation to the current position, and a number without a prefix specifies an absolute position 🌈.
Z — the glow-up version of z 💖
[Only new quoting rules] Similar to z, but scrolls to the next or previous window that contains at least one new or flagged message 🔥. Main character energy only, bestie.
🌈 COMMAND ESCAPES 🌈
Command escapes are available in "Compose mode" during interactive usage, when explicitly requested via -~, and in batch mode (-#) ✨. They perform special functions, like editing headers of the message being composed, calling normal "COMMANDS", yielding a shell, etc. 🫶
Command escapes are only recognized at the beginning of lines, and consist of an escape followed by a command character 💅. The default escape character is the tilde ~ 🎀.
Unless it says otherwise somewhere else, command escapes are the ones responsible for making sure the error number ! and the exit status ? get updated properly, bestie. The variable errexit is the one calling the shots on whether a failed operation errors out message compose mode and causes program exit. Escapes may be prefixed by none to multiple single character command modifiers, and interspersed whitespace is just ignored, she doesn't care:
- You can get an effect equivalent to the command modifier
ignerrwith the hyphen-minus-, which overrideserrexit. Very "no thoughts, head empty, still sending" energy. - The modifier dollar
$evaluates the remains of the line; also see “Shell-style argument quoting”. [v15 behaviour may differ] For now the entire input line is evaluated as a whole, so to avoid control operators like semicolon;being interpreted unintentionally, they must be quoted. Protect her, she's trying her best 💅
Addition of the command line to the [Option]al history can be prevented by placing whitespace directly after escape. And the [Option]al key bindings support a compose mode specific context. The following command escapes are supported, and honestly, they ate:
~~string — Insert the string of text in the message prefaced by a single~. (If the escape character has been changed, that character must be doubled instead.) 🪄~!command — Execute the indicated shell command which follows, replacing unescaped exclamation marks with the previously executed command if the internal variablebangis set, then return to the message. 🫡~.— End compose mode and send the message. The hookson-compose-splice-shellandon-compose-splice, in order, will be called when set, after which, in interactive modeaskatend(leading toaskcc,askbcc) andaskattachwill be checked as well asasksend, after which a seton-compose-leavehook will be called,autoccandautobccwill be joined in if set, finally a givenmessage-inject-tailwill be incorporated, after which the compose mode is left. Yeah it's a whole pipeline, it's giving ✨ ceremony ✨~:S-nail-command or~_S-nail-command — Can be used to execute “COMMANDS” (which are allowed in compose mode). 🎀~<filename — Identical to~r. (twins fr fr)~<!command — command is executed using the shell. Its standard output is inserted into the message. 🐚~?— [Option] Write a summary of command escapes. She gives you the cheat sheet 💖~@[filename...] — Append or edit the list of attachments. Does not manage the error number!and the exit status?(please use~^if error handling is necessary). The append mode expects a list of filename arguments as shell tokens (see “Shell-style argument quoting”; token-separating commas are ignored, too), to be interpreted as documented for the command line option-a, with the message number exception as below.
Without filename arguments the attachment list is edited, entry by entry; if a filename is left empty, that attachment is deleted from the list; once the end of the list is reached either new attachments may be entered or the session can be quit by committing an empty “new” attachment. In non-interactive mode or in batch mode (-#) the list of attachments is effectively not edited but instead recreated; again, an empty input ends list creation.
For all modes, if a given filename solely consists of the number sign # followed by either a valid message number of the currently active mailbox, or by a period ., referring to the current message of the active mailbox, the so-called “dot”, then the given message is attached as a message/rfc822 MIME message part. The number sign must be quoted to avoid misinterpretation as a shell comment character. 🙈
~|command — Pipe the message text through the specified filter command. If the command gives no output or terminates abnormally, retain the original text of the message. The commandfmt(1)is often used as a rejustifying filter.
If the first character of the command is a vertical bar, then the entire message including header fields is subject to the filter command, so ~|| echo Fcc: /tmp/test; cat will prepend a file-carbon-copy message header. Also see ~e, ~v. 😌
~^cmd [subcmd [arg3 [arg4]]] — Inspect and modify the message using the semantics ofdigmsg, therefore arguments are evaluated according to “Shell-style argument quoting”. Error number!and exit status?are not managed: errors are handled via the protocol, and hard errors like I/O failures cannot be handled. ⚠️
The protocol consists of command lines followed by (a) response line(s). The first field of the response line represents a status code which specifies whether a command was successful or not, whether result data is to be expected, and if, the format of the result data. Response data will be shell quoted as necessary for consumption by readsh, or eval and vpospar, to name a few. Error status code lines may optionally contain additional context:
210— Status ok; the remains of the line are the result.211— Status ok; the rest of the line is optionally used for more status. What follows are lines of result addresses, terminated by an empty line. All the input, including the empty line, must be consumed before further commands can be issued. Address lines consist of two token, first the plain network address, e.g.,bob@exam.ple, followed by the (quoted) full address as known:'(Lovely) Bob <bob@exam.ple>'. Non-network addresses use the first field to indicate the type (hyphen-minus-for files, vertical bar|for pipes, and number sign#for names which will undergo alias processing) instead, the actual value will be in the second field.212— Status ok; the rest of the line is optionally used for more status. What follows are lines of furtherly unspecified (quoted) string content, terminated by an empty line. All the input, including the empty line, must be consumed before further commands can be issued.500— Syntax error; invalid command.501— Syntax error or otherwise invalid parameters or arguments.505— Error: an argument fails verification. For example an invalid address has been specified (also seeexpandaddr), or an attempt was made to modify anything in S-nail's own namespace, or a modifying subcommand has been used on a read-only message.506— Error: an otherwise valid argument is rendered invalid due to context. For example, a second address is added to a header which may consist of a single address only.
If a command indicates failure then the message will have remained unmodified. Most commands can fail with 500 if required arguments are missing, or excessive arguments have been given (false command usage). ([v15 behaviour may differ] The latter does not yet occur regularly, because as stated in “Shell-style argument quoting” our argument parser is not yet smart enough to work on subcommand base; for example one might get excess argument error for a three argument subcommand that receives four arguments, but not for a four argument subcommand which receives six arguments: here excess will be joined.) The following (case-insensitive) commands are supported, periodt:
attachment— This command allows listing, removal and addition of message attachments. The second argument specifies the subcommand to apply, one of:attribute— This uses the same search mechanism as described forremoveand prints any known attributes of the first found attachment via212upon success or501if no such attachment can be found. The attributes are written as lines with a keyword and a value token. 🔍attribute-at— This uses the same search mechanism as described forremove-atand is otherwise identical toattribute.attribute-set— This uses the same search mechanism as described forremove, and will set the attribute given as the fourth to the value given as the fifth token argument. If the value is an empty token, then the given attribute is removed, or reset to a default value if existence of the attribute is crucial.
It returns via 210 upon success, with the index of the found attachment following, 505 for message attachments or if the given keyword is invalid, and 501 if no such attachment can be found. The following keywords may be used (case-insensitively):
filename✨ — sets the filename of the MIME part, aka the name that gets used for display and when you're (suggesting a name for) saving it, bestie.content-description— hangs some descriptive info off the attachment's content 🎀, and some MUAs will lowkey prefer this over the plain filename.content-id— for uniquely identifying MIME entities in several contexts 👑; heads up, this one expects a special reference address format as defined in RFC 2045, and if the address content verification fails it throws a ‘505’ at you 💀.content-type— defines the media type/subtype of the part. It's managed automatically, but yes you can overwrite it, slay.content-disposition— automatically set to the string ‘attachment’.attribute-set-at— uses the same search mechanism as described forremove-at, and is otherwise literally identical toattribute-set.insert— adds the attachment given as the third argument, specified exactly as documented for the command line option-a, and it supports the message number extension as documented for~@. Reports ‘210’ on success with the index of the new attachment following it 🫶, ‘505’ if the given file can't be opened, ‘506’ if an on-the-fly character set conversion fails, otherwise ‘501’ gets reported — and that ‘501’ also shows up if character set conversion is requested but just isn't available. No cap.list— lists all attachments via ‘212’, or reports ‘501’ if there are like, no attachments. This one is the default command ofattachmentwhen no second argument has been given 💅.remove— removes the attachment given as the third argument, reporting ‘210’ on success or ‘501’ if no such attachment can be found. Here's the tea: if there's any path component in the given argument, then an exact match of the path that was used to create the attachment is used directly. But if only the basename of that path matches, then all attachments get traversed to find an exact match first, and the removal happens afterwards; if multiple basenames match, boom, ‘506’ error. Message attachments are treated as absolute pathnames, periodt.
And if there's no path component in the given argument, then all attachments get searched for filename= parameter matches as well as for matches of the basename of the path that was used when the attachment was created; multiple matches → ‘506’.
remove-at— interprets the third argument as a number and removes the attachment at that list position (counting from one, bestie!), reporting ‘210’ on success, or ‘505’ if the argument isn't a number, or ‘501’ if no such attachment exists.
header— lets you list, inspect and edit message headers 👑. Header name case is not normalized, so use case-insensitive comparison when you're matching names. The second argument picks the subcommand to apply, one of:insert— creates a new or an additional instance of the header given in the third argument, with the header body content as given in the fourth token. It may return ‘501’ if the third argument specifies a free-form header field name that's invalid, or if body content extraction fails to succeed; ‘505’ if any extracted address doesn't pass syntax and/or security checks or on S-nail namespace violations; and ‘506’ to indicate prevention of excessing a single-instance header — note that ‘Subject:’ can be appended to (a space separator gets added automatically first). ‘To:’, ‘Cc:’ and ‘Bcc:’ support the ‘?single’ modifier to enforce treatment as a single addressee, for exampleheader insert To?single: 'exa, <m@ple>'; the word ‘single’ is optional.
‘210’ is returned on success, followed by the name of the header and the list position of the newly inserted instance. The list position is always 1 for single-instance header fields. All free-form header fields are managed in a single list; also see customhdr.
list— without a third argument you get a list of all yet-existing headers via ‘210’; this command is the default command ofheaderif no second argument has been given. A third argument restricts the output to that given header only, which may fail with ‘501’ if no such field is defined.remove— removes all instances of the header given as the third argument, reporting ‘210’ on success, ‘501’ if no such header can be found, and ‘505’ on S-nail namespace violations.remove-at— removes from the header given as the third argument the instance at the list position (counting from one!) given with the fourth argument, reporting ‘210’ on success, or ‘505’ if the list position argument isn't a number or on S-nail namespace violations, and ‘501’ if no such header instance exists.show— shows the content of the header given as the third argument. Depending on the header type this may respond with ‘211’ or ‘212’; any failure results in ‘501’.
In compose-mode you get read-only access to some optional pseudo headers in the S-nail private namespace 🦋:
Mailx-Command:— the name of the command that generates the message, one of ‘forward’, ‘Lreply’, ‘mail’, ‘Reply’, ‘reply’, ‘resend’. This pseudo header always exists (in compose-mode).Mailx-Raw-To:,Mailx-Raw-Cc:,Mailx-Raw-Bcc:— these represent the frozen initial state of these headers before any transformation (alias, alternates, recipients-in-cc etc.) took place.Mailx-Orig-Sender:,Mailx-Orig-From:,Mailx-Orig-To:,Mailx-Orig-Cc:,Mailx-Orig-Bcc:— the values of said headers of the original message that's been addressed by any ofreply,forward,resend. The sender field is special because it's filled in with the sole sender according to RFC 5322 rules, so it may end up equal to the from field.
help,?— shows an abstract of all the above commands via ‘211’ 🌸.version— prints the protocol version via ‘210’.~A— the same as ‘~i Sign’.~a— the same as ‘~i sign’.~bname ... — adds the given names to the list of blind carbon copy recipients 🙈.~cname ... — adds the given names to the list of carbon copy recipients.~d— reads the file specified by theDEADvariable into the message.~e— fires up your text EDITOR 💅 on the message you've collected so far, then plops you right back into compose mode. If you want something more display-oriented, that's~v, and~||gives you a whole pipe-based editing situation instead. ✨~Fmessages — reads the named messages into the message you're sending, and bestie it brings everything: all message headers and MIME parts, no skimping 🫶. It honoursforward-add-ccalong withforward-inject-headandforward-inject-tail. Didn't name any messages? It just grabs the current one, the “dot”. Iconic.~fmessages — reads the named messages into the message you're sending. No messages named? Then it's the current message, the “dot”, again. This one strips down the list of header fields according to the ‘forward’ (with posix: ‘type’) white- and blacklist selection ofheaderpick, and honoursforward-add-cc,forward-inject-headandforward-inject-tail. For MIME multipart messages, only the first displayable part gets included. 🎀~H— in interactive mode, this edits the message header fields ‘From:’, ‘Reply-To:’ and ‘Sender:’ by typing each one in turn and letting you edit the field. The default values for these come from thefrom,reply-toandsendervariables. In non-interactive mode this sets^ERR-NOTTY. 💀~h— in interactive mode, edits the message header fields ‘To:’, ‘Cc:’, ‘Bcc:’ and ‘Subject:’, one at a time, each one typed in turn and editable by you. In non-interactive mode this sets^ERR-NOTTY. Same energy, different fields.~Ivariable — inserts the value of the named variable into the message. If the variable is unset or empty, the message stays exactly as it was, untouched. Any embedded character sequences\t(horizontal tabulator) and\n(line feed) get expanded in posix mode; otherwise the expansion should happen at set time ([v15 behaviour may differ] by using the command modifierwysh). 🌸~ivariable — literally~Ibut it appends a newline character at the end. That's the whole difference, periodt.~Mmessages — reads the named messages into the message being sent, indented byindentprefix. No messages named? Current message, the “dot”. Honoursforward-add-cc,forward-inject-headandforward-inject-tail.~mmessages — reads the named messages into the message being sent, indented byindentprefix. No messages named? The “dot”, bestie. This one strips down the header field list according to the ‘type’ white- and blacklist selection ofheaderpick, and honoursforward-add-cc,forward-inject-headandforward-inject-tail. For MIME multipart messages, only the first displayable part is included. 🦋~p— displays the message collected so far, prefaced by the message header fields and followed by the attachment list, if there is one. A little preview moment 👑~Q— reads in the given / current message(s) using the algorithm ofquote(except that one is implicitly assumed, even if it isn't set), honouringquote-add-cc.~q— aborts the message being sent, copying it to the file specified by theDEADvariable ifsaveis set. No take-backs, but also no lost work (whensavesays so).~Rfilename — identical to~r, except it indents every line it read byindentprefix. 🎀~rfilename [HERE-delimiter] — reads the named file into the message; the file is object to “Filename transformations”, excluding shell globs and variable expansions. If filename is the hyphen-minus-, then standard input is used instead (for pasting, for example). Only in this latter mode may HERE-delimiter be given: if it is, data will be read in until the given HERE-delimiter is seen on a line by itself, and hitting EOF is an error. The HERE-delimiter is a required argument in non-interactive mode. If it is single-quote quoted then the pasted content will not be expanded, [v15 behaviour may differ] otherwise a future version of S-nail may perform shell-style expansion on the content. Ngl, read that part twice. 🙈~sstring — makes the named string become the current subject field. Newline (NL) and carriage-return (CR) bytes are invalid here and get normalized to space (SP) characters. So don't try it. 💀~tname ... — adds the given name(s) to the direct recipient list. Besties, assemble. 🫶~Umessages — reads in the given / current message(s) excluding all headers, indented byindentprefix. Honoursforward-add-cc,forward-inject-headandforward-inject-tail.~umessages — reads in the given / current message(s), excluding all headers. Honoursforward-add-cc,forward-inject-headandforward-inject-tail. (Yes, same family as~U, the indent is the whole plot twist.)~v— invokes the VISUAL editor on the message collected so far, then returns to compose mode.~eis the option for a less display oriented editor, and~||offers a pipe-based editing approach. 🌈~wfilename — writes the message onto the named file, which is object to the usual “Filename transformations”. If the file already exists, the message gets appended to it. No overwrite drama.~x— same as~q, except the message isn't saved at all. Gone. Poof. ✨
🎀 INTERNAL VARIABLES 🎀
Internal S-nail variables are controlled via the set and unset commands. Little hack for you: prefixing a variable name with the string ‘no’ and calling set does the exact same thing as using unset — so unset crt and set nocrt are the same move. varshow will give you more insight on the given variable(s), and set, when called without arguments, will show a listing of all the variables. Both commands support a more verbose listing mode too. Some well-known variables also become inherited from the program “ENVIRONMENT” implicitly, while others can be imported explicitly with the command environ and henceforth share said properties. 👑
Two different kinds of internal variables exist, and both of them can also form chains. There are boolean variables, which can only be in one of the two states “set” and “unset”, and value variables with a(n optional) string value. For the latter, proper quoting is necessary upon assignment time — the section “COMMANDS” documents the supported quoting rules. 💅
? wysh set one=val\ 1 two="val 2" \
three='val "3"' four=$'val \'4\''; \
varshow one two three four; \
unset one two three four
Dependent upon the actual option, string values may become interpreted as colour names, command specifications, normal text, etc. They may be treated as numbers, in which case decimal values are expected if that's what's documented — but otherwise any numeric format and base that is valid and understood by the vexpr command may be used, too. 🌸
There's also a special kind of string value, the “boolean string”, which must either be a decimal integer (in which case 0 is false and 1 and any other value is true) or any of the (case-insensitive) strings off, no, n and false for a false boolean, and on, yes, y and true for a true boolean. A special kind of boolean string is the “quadoption”: it can optionally be prefixed with the (case-insensitive) term ask-, as in ask-yes; in interactive mode the user will be prompted, otherwise the actual boolean is used. 👀
Variable chains extend a plain ‘*variable*’ with ‘*variable*-HOST’ and ‘*variable*-USER@HOST’ variants. Here ‘HOST’ will be converted to all lowercase when looked up (but not when the variable is set or unset!), [Option]ally IDNA converted, and indeed means ‘server:port’ if a ‘port’ had been specified in the contextual Uniform Resource Locator URL, see “On URL syntax and credential lookup”. Even though this mechanism is based on URLs, no URL percent encoding may be applied to neither of ‘USER’ nor ‘HOST’ — variable chains need to be specified using raw data; that mentioned section contains examples. Variables which support chains are explicitly documented as such, and S-nail treats the base name of any such variable special, meaning users should not create custom names like ‘variable-xyz’ in order to avoid false classifications and treatment of such variables. 🚨
✨ Initial settings ✨
The standard POSIX 2008/Cor 2-2016 mandates the following initial variable settings: noallnet, noappend, asksub, noaskbcc, noautoprint, nobang, nocmd, nocrt, nodebug, nodot, escape set to ~, noflipr, nofolder, header, nohold, noignore, noignoreeof, nokeep, nokeepsave, nometoo, nooutfolder, nopage, prompt set to ? , noquiet, norecord, save, nosendwait, noshowto, noSign, nosign, toplines set to 5. That's the whole mandated starter pack, no omissions. 🎀
However, S-nail has built-in some initial (and some default) settings which (may) diverge, and others may become adjusted by one of the “Resource files”. Displaying the former is accomplished via set:
$ s-nail -:/ -v -Xset -Xx
In general this implementation sets (and has extended the meaning of) sendwait, and does not support the noonehop variable — use command line options or mta-arguments to pass options through to a mta. The default global resource file sets, among others, the variables hold, keep and keepsave, establishes a default headerpick selection etc., and should thus be taken into account. Don't sleep on the defaults, fr fr. 💜
💖 Variables 💖
?— (Read-only) The exit status of the last command, or the return value of the macro called last. This status has a meaning in the state machine: in conjunction witherrexit, any non-0 exit status will cause a program exit, and in posix mode any error while loading (any of the) resource files will have the same effect.ignerr, one of the “Command modifiers”, can be used to instruct the state machine to ignore errors. 👑!— (Read-only) The current error number (errno(3)), which is set after an error occurred; it is also available via^ERR, and the error name and documentation string can be queried via^ERRNAMEand^ERRDOC. [v15 behaviour may differ] This machinery is new and the error number is only really usable if a command explicitly states that it manages the variable!— for otherserrnowill be used in case of errors, or^ERR-INVALif that is 0: it thus may or may not reflect the real error. The error number may be set with the commandreturn. 💀^(Read-only) — okay bestie, this one is THE multiplexer variable, and it does dynamic expansion of whatever state or condition you asked for, which honestly is giving main character energy. Here's the whole roster:^ERR,^ERRDOC,^ERRNAME— the number, the documentation, and the name of the currenterrno(3), respectively, and it's usually set right after an error happened. The documentation is an[Option]al, and the name gets used if the doc isn't available.[v15 behaviour may differ]— no cap, this machinery is new, and it's usually only reliable if a command explicitly says it manages the variable!, which is effectively identical to^ERR. Each of these variables can be suffixed with a hyphen minus followed by a name or a number, and then the expansion refers to that given error. Heads up: this is a direct mapping of (a subset of) the system error values:
define work {
eval echo \$1: \$^ERR-$1:\
\$^ERRNAME-$1: \$^ERRDOC-$1
vput vexpr i + "$1" 1
if [ $i -lt 16 ]
\xcall work $i
end
}
call work 0
^ERRQUEUE-COUNT,^ERRQUEUE-EXISTS— the number of messages in the[Option]al queue of errors, and a string telling you the queue state:emptyor the (translated) “ERROR”. 💀 They are always0and the empty string, respectively, unlessfeaturesincludes,+errors,.
*(Read-only) — expands all positional parameters (see 1), separated by the first character of the value ofifs.[v15 behaviour may differ]— the special semantics of the equally named special parameter of thesh(1)are not yet supported, so don't come for her.@(Read-only) — expands all positional parameters (see 1), separated by a space character. And here's the slay part: if you place it inside double quotation marks, each positional parameter is properly quoted so it expands back to a single parameter again. ✨#(Read-only) — expands to the number of positional parameters, i.e., the size of the positional parameter stack, in decimal.0(Read-only) — inside the scope of a defined and called macro this expands to the name of the calling macro, or to the empty string if the macro is running from top-level. For the[Option]al regular expression search and replace operator ofvexpr, this expands to the entire matching expression. And in global context, it represents the program name. 🫶1(Read-only) — this is your access to the positional parameter stack. All the further parameters can be accessed with this syntax too: ‘2’, ‘3’ etc.; positional parameters can be shifted off the stack by callingshift. The parameter stack contains, for example, the arguments of a called defined macro, the matching groups of the[Option]al regular expression search and replace expression ofvexpr, and it can be explicitly created or overwritten with the commandvpospar.account(Read-only) — is set to the active account. Simple as that, bestie.add-file-recipients(Boolean) — when file or pipe recipients have been specified, this mentions them in the corresponding address fields of the message instead of silently stripping them from their recipient list. By default, such addressees are not mentioned. 🙈allnet(Boolean) — causes only the local part to be evaluated when comparing addresses.append(Boolean) — causes messages saved in the “secondary mailbox”MBOXto be appended to the end rather than prepended. And lowkey? This should always be set.askatend(Boolean) — causes the prompts for ‘Cc:’ and ‘Bcc:’ lists to appear after the message has been edited.askattach(Boolean) — if set, S-nail asks an interactive user for files to attach at the end of each message; an empty line finalizes the list.askcc(Boolean) — causes the interactive user to be prompted for carbon copy recipients (at the end of each message ifaskatendorbsdcompatare set).askbcc(Boolean) — causes the interactive user to be prompted for blind carbon copy recipients (at the end of each message ifaskatendorbsdcompatare set).asksend(Boolean) — causes the interactive user to be prompted for confirmation to send the message or to reenter compose mode, after having been shown a preliminary envelope summary.asksign(Boolean)[Option]— causes the interactive user to be prompted if the message is to be signed at the end of each message. Careful though: thesmime-signvariable is ignored when this variable is set. 💅asksub(Boolean) — causes S-nail to prompt the interactive user for the subject upon entering compose mode, unless a subject already exists.attrlist— a sequence of characters to display in the ‘attribute’ column of the headline as shown in the display of headers; each one is for one type of message (see “Message states”), with the default beingNUROSPMFAT+-$~orNU *HMFAT+-$~if thebsdflagsvariable is set, in the following order:- ‘
N’ — new. - ‘
U’ — unread but old. - ‘
R’ — new but read. - ‘
O’ — read and old. - ‘
S’ — saved. - ‘
P’ — preserved. - ‘
M’ — mboxed. - ‘
F’ — flagged. - ‘
A’ — answered. - ‘
T’ — draft. - ‘
+’ —[v15 behaviour may differ]start of a (collapsed) thread in threaded mode (seeautosort,thread); - ‘
-’ —[v15 behaviour may differ]an uncollapsed thread in threaded mode; only used in conjunction with-L. - ‘
$’ — classified as spam. - ‘
~’ — classified as possible spam.
- ‘
autobcc— specifies a list of recipients to which a blind carbon copy of each outgoing message will be sent automatically.autocc— specifies a list of recipients to which a carbon copy of each outgoing message will be sent automatically.autocollapse(Boolean) — causes threads to be collapsed automatically when.Ql thread Ns ed sort modeis entered (see thecollapsecommand).autoprint(Boolean) — enables automatic typeing of a(n existing) “successive” message afterdeleteandundeletecommands: the message that becomes the new “dot” is shown automatically, as viadpordt.autosort— causes sorted mode (see thesortcommand) to be entered automatically, with the value of this variable as the sorting method, when a folder is opened — for exampleset autosort=thread. 🔥bang(Boolean) — enables the substitution of all not (reverse-solidus) escaped exclamation mark ‘!’ characters by the contents of the last executed command, for the!shell escape command and~!, one of the compose mode “COMMAND ESCAPES”. If this variable is not set, no reverse solidus stripping is performed.bind-timeout—[Obsolete]predecessor ofbind-inter-byte-timeout.[v15 behaviour may differ]Setting this automatically sets the successor.bind-inter-byte-timeout[Option]— terminals may generate multi-byte sequences for special function keys, for example, but these sequences may not become read as a unit. And multi-byte sequences can be defined freely viabind. This variable specifies the timeout in milliseconds that the MLE (see “On terminal control and line editor”) waits for more bytes to arrive, unless it considers a sequence “complete”. The default is200, the maximum is about 10 seconds. In the following example, the comments state which sequences are affected by this timeout:
? bind base abc echo 0 # abc
? bind base ab,c echo 1 # ab
? bind base abc,d echo 2 # abc
? bind base ac,d echo 3 # ac
? bind base a,b,c echo 4
? bind base a,b,c,d echo 5
? bind base a,b,cc,dd echo 6 # cc and dd
bind-inter-key-timeout[Option]— multi-key bind sequences do not time out by default. If this variable is set, then the current key sequence is forcefully terminated once the timeout (in milliseconds) triggers. The value should be (maybe significantly) larger thanbind-inter-byte-timeout, but it may not excess the maximum, too. 🙈bsdcompat(Boolean) — sets some cosmetical features to traditional BSD style; it has the same affect as settingaskatendand all other variables prefixed with ‘bsd’; it also changes the behaviour ofemptystart(which does not exist in BSD).bsdflags(Boolean) — changes the letters shown in the first column of a header summary to traditional BSD style.bsdheadline(Boolean) — changes the display of columns in a header summary to traditional BSD style.bsdmsgs(Boolean) — changes some informational messages to traditional BSD style.bsdorder(Boolean) — causes the ‘Subject:’ field to appear immediately after the ‘To:’ field in message headers, and with the~h“COMMAND ESCAPES”.build-cc,build-ld,build-os,build-rest(Read-only) — the build environment, including the compiler, the linker, the operating system S-nail has been build for — usually taken fromuname(1)viauname -s, and then lowercased — as well as all the possibly interesting rest of the configuration and build environment. This info is also available in the verbose output of the commandversion. 👑
charset-7bit— the value that should show up in thecharset=parameter ofContent-Type:MIME header fields whenever no character set conversion of the message data was performed. It defaults to US-ASCII, and bestie, the character set you pick here should be US-ASCII compatible. 💅charset-8bit— [Option] the default 8-bit character set used as an implicit last member of the variablesendcharsets. Defaults to UTF-8 if character set conversion capabilities are available, and to ISO-8859-1 otherwise — unless the operating system environment is known to always and exclusively support UTF-8 locales, in which case the only supported character set isttycharsetand this variable is effectively ignored. 💀charset-unknown-8bit— [Option] RFC 1428 lays out the conditions under which internet mail gateways shall "upgrade" the content of a mail message by using a character set with the nameunknown-8bit. Now because of the unclassified nature of this character set, S-nail will not be capable of converting it to any other character set, periodt. But if this variable is set, any message part that uses the character setunknown-8bitis assumed to really be in the character set given in the value; otherwise the (final) value ofcharset-8bitis used for that purpose. 🌈
This variable will also be taken into account if a MIME type (see "The mime.types files") of a MIME message part that uses the binary character set is forcefully treated as text.
cmd— the default value for the pipe command. 🫶colour-disable— (Boolean)[Option] forcefully disable usage of colours. Also see the section "Coloured display". 🎀colour-pager— (Boolean)[Option] whether colour shall be used for output that is paged throughPAGER. Heads up though: pagers may need special command line options — like,less(1)requires the option-Randlv(1)the option-cin order to support colours. Often doing manual adjustments is unnecessary since S-nail may perform adjustments dependent on the value of the environment variablePAGER(see there for more). 🌸contact-mail,contact-web— (Read-only) addresses for contact per email and web, respectively, for bug reports, suggestions, or literally anything else regarding S-nail. The former can be used directly:? eval mail $contact-mail. 💖content-description-forwarded-message,content-description-quote-attachment,content-description-smime-message,content-description-smime-signature— [Option](partially) strings which will be placed in accordingContent-Description:headers if non-empty. They all have default values, for exampleForwarded message. ✨crt— in a(n interactive) terminal session, then if this valued variable is set it will be used as a threshold to determine how many lines the given output has to span before it will be displayed via the configuredPAGER; usage of thePAGERcan be forced by setting this to the value0, and setting it without a value will deduce the current height of the terminal screen to compute the threshold (seeLINES,screenandstty(1)). [v15 behaviour may differ] rn this uses the count of lines of the message in wire format, which, dependent on the mime-encoding of the message, is unrelated to the number of display lines. (The software is old and historically the relation was a given thing.) 😭customhdr— define a set of custom headers to be injected into newly composed or forwarded messages. A custom header consists of the field name followed by a colon:and the field content body. Standard header field names cannot be overwritten by a custom header, with the exception ofComments:andKeywords:. Different to the command line option-Cthe variable value is interpreted as a comma-separated list of custom headers: to include commas in header bodies they need to become escaped with reverse solidus\. Headers can be managed more freely in "Compose mode" via~^. 🦋
? set customhdr='Hdr1: Body1-1\, Body1-2, Hdr2: Body2'
datefield— controls the appearance of the%ddate and time format specification of the headline variable, that is used, for example, when viewing the summary of headers. If unset, then the local receiving date is used and displayed unformatted; otherwise the message sendingDate:. It is possible to assign astrftime(3)format string and control formatting, but embedding newlines via the%nformat is not supported, and will result in display errors. The default is%Y-%m-%d %H:%M, and also seedatefield-markout-older. 🍓datefield-markout-older— only used in conjunction withdatefield. Can be used to create a visible distinction of messages dated more than a day in the future, or older than six months, a concept comparable to the-loption of the POSIX utilityls(1). If set to the empty string, then the plain month, day and year of theDate:will be displayed, but astrftime(3)format string to control formatting can be assigned. The default is%Y-%m-%d. 💜debug— (Boolean) (Almost) enter a debug-only sandbox mode which generates many log messages, disables the actual delivery of messages, and also impliesnorecordas well asnosave. Also seeverbose. 🔥disposition-notification-send— (Boolean)[Option] emit aDisposition-Notification-To:header (RFC 3798) with the message. This requires thefromvariable to be set. 👑dot— (Boolean) whendotis set, a period.on a line by itself during message input in (interactive or batch-#) "Compose mode" will be treated as end-of-message (in addition to the normal end-of-file condition). This behaviour is implied inposixmode with a setignoreeof. ⭐dotlock-disable— (Boolean)[Option] disable creation of "dotlock files" for MBOX databases. 🎀dotlock-ignore-error— [Obsolete](Boolean)[Option] ignore failures when creating "dotlock files". Please usedotlock-disableinstead. 🙈editalong— if this variable is set then the editor is started automatically when a message is composed in interactive mode. If the value starts with the lettervthen this acts as if~v, otherwise as if~e(see "COMMAND ESCAPES") had been specified. Theeditheadersvariable is implied for this automatically spawned editor session. 🧚editheaders— (Boolean) when a message is edited while being composed, its header is included in the editable text. 📝emptystart— (Boolean) when entering interactive mode S-nail normally writes "No mail for user" and exits immediately if a mailbox is empty or does not exist. If this variable is set S-nail starts even with an empty or non-existent mailbox (the latter behaviour furtherly depends uponbsdcompat, though). 🌈errexit— (Boolean) let each command with a non-0exit status, including every called macro which returns a non-0status, cause a program exit unless prefixed byignerr(see "Command modifiers"). This also affects "COMMAND ESCAPES", but which use a different modifier for ignoring the error. Please refer to the variable?for more on this topic. 💀errors-limit— [Option] maximum number of entries in the errors queue. 📋escape— the first character of this value defines the escape character for "COMMAND ESCAPES" in "Compose mode". The default value is the character tilde~. If set to the empty string, command escapes are disabled. ✨expandaddr— if unset only user name and email address recipients are allowed "On sending mail, and non-interactive mode". If set without value all possible recipient types will be accepted. A value is parsed as a comma-separated list of case-insensitive strings, and if that containsrestrictbehaviour equals the former except when in interactive mode or if "COMMAND ESCAPES" were enabled via-~or-#, in which case it equals the latter, allowing all address types.restrictreally acts likerestrict,-all,+name,+addr, so care for ordering issues must be taken. 🫶
Recipient types can be added and removed with a plus sign + or hyphen-minus - prefix, respectively. By default invalid or disallowed types are filtered out and cause a warning, hard send errors need to be enforced by including fail. The value all covers all types, fcc whitelists Fcc: header targets regardless of other settings, file file targets (it includes fcc), pipe command pipeline targets, name user names still unexpanded after alias and mta-aliases processing and thus left for expansion by the mta (invalid for the built-in SMTP one), and addr network addresses. Targets are interpreted in the given order, so that restrict,fail,+file,-all,+addr will cause hard errors for any non-network address recipient address unless running interactively or having been started with the option -~ or -#; in the latter case(s) any type may be used. 💜
expandaddr— (still going, bestie, we're in the thick of it 🫶)
User name receivers addressing valid local users can be expanded to fully qualified network addresses (also see hostname) by including nametoaddr in the list.
Historically invalid recipients were stripped off without causing errors — this can be changed by making failinvaddr an entry of the list (it really acts like failinvaddr,+addr).
Likewise, domaincheck (really domaincheck,+addr) compares address domain names against a whitelist and strips off (fail for hard errors) addressees which fail this test; the domain name localhost and the non-empty value of hostname (the real hostname otherwise) are always whitelisted, and expandaddr-domaincheck can be set to extend this list.
Finally, some address providers (for example -b, -c and all other command line recipients) will be evaluated as if specified within dollar-single-quotes (see "Shell-style argument quoting") if the value list contains the string shquote.
expandaddr-domaincheck— can be set to a comma-separated list of domain names that should be whitelisted for the evaluation of thedomaincheckmode ofexpandaddr. Heads up: IDNA encoding is not automatically performed, so useaddrcodecto prepare the domain (of an address) yourself. 💅expandargv— unless this variable is set, additionalmta(Mail-Transfer-Agent) arguments from the command line, as can be given after a--separator, result in a program termination with failure status. The same can be accomplished by using the special (case-insensitive) valuefail. A lesser strict variant is the otherwise identicalrestrict, which does accept such arguments in interactive mode, or if tilde commands were enabled explicitly by using one of the command line options-~or-#. The empty value will allow unconditional usage. ✨features— (Read-only) String giving a list of optional features. Features are preceded with a plus sign+if they are available, with a hyphen-minus-otherwise. To ease substring matching the string starts and ends with a comma. The output of the commandversionincludes this information in a more pleasant output. 🎀flipr— (Boolean) This setting reverses the meanings of a set of reply commands, turning the lowercase variants, which by default address all recipients included in the header of a message (reply,respond,followup), into the uppercase variants, which by default address the sender only (Reply,Respond,Followup) — and vice versa. It's giving chaos, but make it intentional 🔥folder— the default path under which mailboxes are to be saved: filenames that begin with the plus sign+will have the plus sign replaced with the value of this variable if set, otherwise the plus sign will remain unchanged when doing "Filename transformations"; also see folder for more on this topic, and know about standard imposed implications ofoutfolder. The value supports a subset of transformations itself, and if the non-empty value does not start with a solidus/, then the value ofHOMEwill be prefixed automatically. Once the actual value is evaluated first, the internal variablefolder-resolvedwill be updated for caching purposes. 👑folder-hook-FOLDER,folder-hook— names a defined macro which will be called whenever a folder is opened. The macro will also be invoked when new mail arrives, but message lists for commands executed from the macro only include newly arrived messages then.localoptsare activated by default in a folder hook, causing the covered settings to be reverted once the folder is left again.
The specialized form will override the generic one if FOLDER matches the file that is opened. Unlike other folder specifications, the fully expanded name of a folder, without metacharacters, is used to avoid ambiguities. However, if the mailbox resides under folder then the usual + specification is tried in addition, so that if folder is mail (and thus relative to the user's home directory) then /home/usr1/mail/sent will be tried as folder-hook-/home/usr1/mail/sent first, but then followed by folder-hook-+sent. Both, because ✨thoroughness✨.
folder-resolved— (Read-only) Set to the fully resolved path offolderonce that evaluation has occurred; rather internal. Don't worry about it, it's doing its little behind-the-scenes job. 🙈followup-to— (Boolean) Controls whether aMail-Followup-To:header is generated when sending messages to known mailing lists. The user as determined viafrom(or, if that contains multiple addresses,sender) will be placed in there if any list addressee is not a subscribed list. Also seefollowup-to-honourand the commandsmlist,mlsubscribe,replyandLreply. 💌followup-to-add-cc— (Boolean) Controls whether the user will be added to the messages'Cc:list in addition to placing an entry inMail-Followup-To:(seefollowup-to). Double presence, double slay. 🦋followup-to-honour— controls whether aMail-Followup-To:header is honoured when group-replying to a message viareplyorLreply. This is a "quadoption"; if set without a value it defaults to "yes", and seefollowup-to. ✨forward-add-cc— (Boolean) Whether senders of messages forwarded via~F,~f,~m,~Uor~ushall be made members of the carbon copiesCc:list. 🫶forward-as-attachment— (Boolean) Original messages are normally sent as inline text with theforwardcommand, and only the first part of a multipart message is included. With this setting enabled, messages are sent as unmodified MIMEmessage/rfc822attachments with all of their parts included. The whole thing, no crumbs left behind. 🍓forward-inject-head,forward-inject-tail— the strings to put before and after the text of a message with theforwardcommand, respectively. The former defaults to-------- Original Message --------\n. Special format directives in these strings will be expanded if possible, and if so configured the output will be folded according toquote-fold; for more please refer toquote-inject-head.
Watch out bestie: injections will not be performed by forward if the variable forward-as-attachment is set — the "COMMAND ESCAPES" ~F, ~f, ~M, ~m, ~U, ~u always inject though. 💅
from— the address (or a list of addresses) to put into theFrom:field of the message header, quoting RFC 5322: the author(s) of the message, that is, the mailbox(es) of the person(s) or system(s) responsible for the writing of the message. According to that RFC setting thesendervariable is required iffromcontains more than one address.[v15 behaviour may differ]Please expect automatic management of thefromandsenderrelationship. Dependent on the context these addresses are handled as if they were in the list ofalternates.
If a file-based MTA is used, then from (or, if that contains multiple addresses, sender) can nonetheless be used as the envelope sender address at the MTA protocol level (the RFC 5321 reverse-path), either via the -r command line option (without argument; see there for more), or by setting r-option-implicit.
If the machine's hostname is not valid at the Internet (for example at a dialup machine), then either this variable or hostname ([v15-compat] a SMTP-based mta adds even more fine-tuning capabilities with smtp-hostname) have to be set: if so the message and MIME part related unique ID fields Message-ID: and Content-ID: will be created (except when disallowed by message-id-disable or stealthmua). 🌸
fullnames— (Boolean) Due to historical reasons 😭 comments and name parts of email addresses are removed by default when sending mail, replying to or forwarding a message. If this variable is set, such stripping is not performed. Names stay. Periodt. 👑fwdheading— [Obsolete] Predecessor offorward-inject-head. Ancient. Iconic, but ancient. 💀header— (Boolean) Causes the header summary to be written at startup and after commands that affect the number of messages or the order of messages in the current folder. Unless in posix mode a header summary will also be displayed on folder changes. The command line option-Ncan be used to setnoheader. 🎀headline— a format string to use for the summary of headers. Format specifiers in the given string start with a percent sign%and may be followed by an optional decimal number indicating the field width — if that is negative, the field is to be left-aligned. Names and addresses are subject to modifications according toshownameandshowto. Valid format specifiers are: ⬇️%%— just a plain percent sign, nothing extra 💅%>— the “Dotmark”: it's a space character, except for the current message (the “dot”), for which it expands to>(this depends onheadline-plain).%<— same Dotmark energy 🌸, another space character, but for the current message (the “dot”) it expands to<(also dependent onheadline-plain).%$— [Option] the spam score of the message, as classified via the commandspamrate. If there's no spam support, all you get is a replacement character, sorry bestie 😭%a— the message attribute character (the status flag); you can adjust the actual content by settingattrlist. Slay 🎀%d— the date found in theDate:header of the message whendatefieldis set (which is the default), otherwise the date the message was received. Formatting is controlled by assigning astrftime(3)format string todatefield(anddatefield-markout-older). So much power ✨%e— the indenting level inthreaded sort mode.%f— the address of the message sender 👑%i— the message thread tree structure. (Note: this format does not support a field width, and it honoursheadline-plain.)%L— mailing list status: is the addressee of the message a knownl(mlist) orLmlsubscribed mailing list? And the letterPannounces the presence of a RFC 2369List-Post:header, which makes a message a valuable target ofLreply. Lowkey iconic 🌈%l— the number of lines of the message, if available.%m— message number.%o— the number of octets (bytes) in the message, if available.%S— message subject (if any) in double quotes.%s— message subject (if any).%t— the position in threaded/sorted order.%U— the value0everywhere except in an IMAP mailbox, where it expands to the UID of the message. IMAP girlies stay winning 💖
The default is
%>%a%m %-18f %16d %4l/%-5o %i%-s
or, if bsdcompat is set,
%>%a%m %20-f %16d %3l/%-5o %i%-S
Also see attrlist, headline-plain and headline-bidi. 🫶
headline-bidi 🌸
Bidirectional text needs special treatment when you're displaying headers, because numbers (think dates, file sizes, that whole vibe) will not affect the current text direction — which in effect gives you ugly line layouts when arabic or other right-to-left text wants to show up. On the other hand, only a minority of terminals can even correctly handle direction changes, so user interaction is straight-up necessary for acceptable results. And note: extended host system support is required regardless — like, detection of the terminal character set is one precondition — and this feature only works in a Unicode (i.e., UTF-8) locale. No cap.
In general, setting this variable makes S-nail encapsulate text fields that may occur when displaying headline (and some other fields too, like dynamic expansions in the prompt) with special Unicode control sequences. You can fine-tune the terminal support level by assigning a value:
- No value (or literally any value other than
1,2and3) → S-nail assumes the terminal can properly deal with Unicode version 6.3, in which case text gets embedded in a pair of U+2068 (FIRST STRONG ISOLATE) and U+2069 (POP DIRECTIONAL ISOLATE) characters. Also, no space on the line is reserved for these characters. Clean. ✨ 1→ weaker support: Unicode 6.3, but reserve the room of two spaces for writing the control sequences onto the line.2→ selects Unicode 1.1 support (U+200E, LEFT-TO-RIGHT MARK).3→ also Unicode 1.1 support (U+200E, LEFT-TO-RIGHT MARK), but this one again reserves room for two spaces in addition.
headline-plain 🦋
(Boolean) On Unicode (UTF-8) aware terminals, enhanced graphical symbols are used by default for certain entries of headline. If this variable is set, only basic US-ASCII symbols will be used. Simple as that 💅
history-file 🎀
[Option] the (expandable) location of a permanent history file for the MLE line editor (“On terminal control and line editor”). Also see history-size.
history-gabby 🗣️
[Option] add more entries to the MLE history than is normally done. A comma-separated list of case-insensitive strings can be used to fine-tune which gabby entries shall be allowed. If it contains errors, erroneous commands will also be added. all adds all optional entries, and is the fallback chattiness identifier of on-history-addition. She talks a lot, but we love her 💖
history-gabby-persist 💾
(Boolean)[Option] the history-gabby entries will not be saved in persistent storage unless this variable is set. The knowledge of whether a persistent entry was gabby is not lost, though. Also see history-file.
history-size 📏
[Option] setting this variable imposes a limit on the number of concurrent history entries. If set to the value 0 then no further history entries will be added — and loading and incorporation of the history-file upon program startup can also be suppressed by doing this. Runtime changes will not be reflected before the history is saved or loaded (again). Fr fr.
hold ✋
(Boolean) this setting controls whether messages are held in the system inbox, and it is set by default.
hostname 🏠
Used instead of the value obtained from uname(3) and getaddrinfo(3) as the hostname when expanding local addresses, for example in From: (also see “On sending mail, and non-interactive mode”, for expansion of addresses that have a valid user-, but no domain name in angle brackets). If either from or this variable is set, the message and MIME part related unique ID fields Message-ID: and Content-ID: will be created (except when disallowed by message-id-disable or stealthmua). And if the [Option]al IDNA support is available (see idna-disable), variable assignment is aborted when a necessary conversion fails. Not me being strict about it 😤
Setting it to the empty string will cause the normal hostname to be used, but nonetheless enables creation of said ID fields. [v15-compat] in conjunction with the built-in SMTP mta smtp-hostname also influences the results: one should produce some test messages with the desired combination of hostname, and/or from, sender etc. first. Test first, vibes second 🧚
idna-disable 🌍
(Boolean)[Option] can be used to turn off the automatic conversion of domain names according to the rules of IDNA (internationalized domain names for applications). Since the IDNA code assumes that domain names are specified with the ttycharset character set, an UTF-8 locale charset is required to represent all possible international domain names (before conversion, that is).
ifs ✂️
The input field separator that is used ([v15 behaviour may differ] by some functions) to determine where to split input data.
- Unsetting is treated as assigning the default value,
\t\n. - If set to the empty value, no field splitting will be performed.
- If set to a non-empty value, all whitespace characters are extracted and assigned to the variable
ifs-ws.ifs-wswill be ignored at the beginning and end of input. Diverging from POSIX shells, default whitespace is removed in addition, which is owed to the entirely different line content extraction rules.- Each occurrence of a character of
ifswill cause field-splitting, and any adjacentifs-wscharacters will be skipped.
ifs-ws 🫧
(Read-only) Automatically deduced from the whitespace characters in ifs.
ignore 🙈
(Boolean) ignore interrupt signals from the terminal while entering messages; instead echo them as @ characters and discard the current line. Very demure.
ignoreeof 🚫
(Boolean) ignore end-of-file conditions (control-D) in “Compose mode” on message input and in interactive command input. If set, an interactive command input session can only be left by explicitly using one of the commands exit and quit, and message input in compose mode can only be terminated by entering a period . on a line by itself, or by using the ~. “COMMAND ESCAPES”; setting this implies the behaviour that dot describes in posix mode.
inbox 📬
If this is set to a non-empty string it will specify the user's “primary system mailbox”, overriding MAIL and the system-dependent default, and (thus) be used to replace % when doing “Filename transformations”; also see folder for more on this topic. The value supports a subset of transformations itself. Main character mailbox energy 👑
indentprefix 🎀
String used by the ~m, ~M and ~R “COMMAND ESCAPES” and by the quote option for indenting messages, in place of the POSIX mandated default tabulator character \t. Also see quote-chars.
keep(Boolean) — bestie, listen: when the “primary system mailbox” file is empty, it normally gets yeeted. Set this and it stays. 💖 Heads up though — if you're inposixmode, any empty file gets removed unless this variable is set. Why care? Because it lowkey improves interoperability with other mail user agents when y'all are sharing a common folder directory, and it also stops malicious users from creating fake mailboxes in a world-writable spool directory. (Okay, that second one is actually huge.) [v15 behaviour may differ] Also real talk: only local regular (MBOX) files are covered here. Maildir and other mailbox types will never be removed, even if empty. Periodt.keep-content-length(Boolean) — so when you're editing messages and writing MBOX mailbox files, S-nail can be told to keep theContent-Length:andLines:header fields that some MUAs generate — that's what this variable does. ✨ Since S-nail neither uses nor updates these non-standardized header fields (which, ngl, is itself a lil demonstration of their conceptual problems 👀), stripping them should increase interoperability between MUAs that work with the same mailbox files. Note: if this is not set butwritebackedited(as below) is, then a possibly performed automatic stripping of these header fields already marks the message as being modified. [v15 behaviour may differ] At some future time S-nail will be capable to rewrite and apply a mime-encoding to modified messages, and then those fields will be stripped silently.keepsave(Boolean) — usually when a message is saved it gets discarded from the originating folder when S-nail quits. 🫶 This setting causes all saved message to be retained. Iconic hoarding behaviour, honestly.line-editor-cpl-word-breaks[Option] — a list of bytes that themle-completetabulator completion uses to decide where word boundaries exist. Default is"'@=;|:🎀 [v15 behaviour may differ] Fair warning: this mechanism is yet restricted.line-editor-disable(Boolean) — turns off any line editing capabilities (from S-nail's POW, see “On terminal control and line editor” for more).line-editor-no-defaults(Boolean) [Option] — do not establish any default key binding. Blank slate energy, we love a fresh start 🌸log-prefix— the error log message prefix string. Its value iss-nail:.mailbox-display(Read-only) — the name of the current mailbox (folder), possibly abbreviated for display purposes. ✨mailbox-resolved(Read-only) — the fully resolved path of the current mailbox. The whole entire truth, no abbreviation 💅mailcap-disable(Boolean) [Option] — turn off consideration of MIME type handlers from, and implicit loading of, “The Mailcap files”.mailx-extra-rc— an additional startup file that is loaded as the last of the “Resource files”. 🦋 Use this file for commands that are not understood by other POSIX mailx(1) implementations, i.e., mostly anything which is not covered by “Initial settings”.markanswered(Boolean) — when a message is replied to and this variable is set, it gets marked as having been answered. See the section “Message states”. Keeping receipts, fr fr ✅mbox-fcc-and-pcc(Boolean) — by default all file and pipe message receivers (seeexpandaddr) will be fed valid MBOX database entry message data (seefolder,mbox-rfc4155), and existing file targets will become extended in compliance to RFC 4155. If this variable is unset, then a plain standalone RFC 5322 message will be written, and existing file targets will be overwritten. ⚠️ Overwritten is overwritten, bestie — mind your targets.mbox-rfc4155(Boolean) — when opening MBOX mailbox databases, and in order to achieve compatibility with old software, the very tolerant POSIX standard rules for detecting message boundaries (so-calledFrom_lines) are used instead of the stricter rules from the standard RFC 4155. This behaviour can be switched by setting this variable.
This may temporarily be handy when S-nail complains about invalid From_ lines when opening a MBOX: in this case setting this variable and re-opening the mailbox in question may correct the result. 👑 If so, copying the entire mailbox to some other file, as in copy * SOME-FILE, will perform proper, all-compatible From_ quoting for all detected messages, resulting in a valid MBOX mailbox. ([v15 behaviour may differ] The better and non-destructive approach is to re-encode invalid messages, as if it would be created anew, instead of mangling the From_ lines; this requires the structural code changes of the v15 rewrite.) Finally the variable can be unset again:
define mboxfix {
localopts yes; wysh set mbox-rfc4155;\
wysh File "${1}"; copy * "${2}"
}
call mboxfix /tmp/bad.mbox /tmp/good.mbox
memdebug(Boolean) — internal development variable. (Keeps memory debug enabled even ifdebugis not set.) Devs only, iykyk 🧚message-id-disable(Boolean) — by setting this variable the generation ofMessage-ID:andContent-ID:message and MIME part headers can be completely suppressed, effectively leaving this task up to the mta (Mail-Transfer-Agent) or the SMTP server. 💀 Note that according to RFC 5321 a SMTP server is not required to add this field by itself, so it should be ensured that it accepts messages withoutMessage-ID.message-inject-head— a string to put at the beginning of each new message, followed by a newline. [Obsolete] The escape sequences tabulator\tand newline\nare understood (use thewyshprefix when setting the variable(s) instead).message-inject-tail— a string to put at the end of each new message, followed by a newline. [Obsolete] The escape sequences tabulator\tand newline\nare understood (use thewyshprefix when setting the variable(s) instead). Also seeon-compose-leave. 🎀metoo(Boolean) — usually, when an alias expansion contains the sender, the sender is removed from the expansion. Setting this option suppresses these removals. Note that a setmetooalso causes a-moption to be passed through to the mta (Mail-Transfer-Agent); though most of the modern MTAs no longer document this flag, no MTA is known which does not support it (for historical compatibility). Main character stays in the group chat 💅mime-allow-text-controls(Boolean) — when sending messages, each part of the message is MIME-inspected in order to classify theContent-Type:andContent-Transfer-Encoding:(seemime-encoding) that is required to send this part over mail transport, i.e., a computation rather similar to what thefile(1)command produces when used with the--mimeoption.
This classification however treats text files which are encoded in UTF-16 (seen for HTML files) and similar character sets as binary octet-streams, forcefully changing any text/plain or text/html specification to application/octet-stream: if that actually happens a yet unset charset MIME parameter is set to binary, effectively making it impossible for the receiving MUA to automatically interpret the contents of the part. 😭
If this variable is set, and the data was unambiguously identified as text data at first glance (by a .txt or .html file extension), then the original Content-Type: will not be overwritten. Slay.
mime-alternative-favour-rich(Boolean) — if this variable is set then rich MIME alternative parts (e.g., HTML) will be preferred in favour of included plain text versions when displaying messages, provided that a handler exists which produces output that can be (re)integrated into S-nail's normal visual display. Fancy version first, always 💖✨mime-counter-evidence— normally theContent-Type:field is used to decide how to handle MIME parts. Some MUAs, however, do not use “The mime.types files” (also see “HTML mail and MIME attachments”) or a similar mechanism to correctly classify content, but specify an unspecific MIME type (application/octet-stream) even for plain text attachments. If this variable is set then S-nail will try to re-classify such MIME message parts, if possible, for example via a possibly existing attachment filename. A non-empty value may also be given, in which case a number is expected, actually a carrier of bits, best specified as a binary value, like0b1111. 🔥- If bit two is set (counting from 1, decimal 2) then the detected mimetype will be carried along with the message and be used for deciding which MIME handler is to be used, for example; when displaying such a MIME part the part-info will indicate the overridden content-type by showing a plus sign
+. - If bit three is set (decimal 4) then the counter-evidence is always produced and a positive result will be used as the MIME type, even forcefully overriding the parts given MIME type.
- If bit four is set (decimal 8) as a last resort the actual content of
application/octet-streamparts will be inspected, so that data which looks like plain text can be treated as such. This mode is even more relaxed when data is to be displayed to the user or used as a message quote (data consumers which mangle data for display purposes, which includes masking of control characters, for example).
- If bit two is set (counting from 1, decimal 2) then the detected mimetype will be carried along with the message and be used for deciding which MIME handler is to be used, for example; when displaying such a MIME part the part-info will indicate the overridden content-type by showing a plus sign
mime-encoding— the MIMEContent-Transfer-Encodingto use in outgoing text messages and message parts, where applicable (7-bit clean text messages are without an encoding if possible):8bit(or8b) — bestie, this one is the "just pass it through raw, no thoughts head empty" option 💅. Like, 8-bit transport basically causes the raw data to go through unchanged, which sounds iconic until you hit ✨problems✨: it can break when you're transferring mail over channels that aren't ESMTP (RFC 1869) compliant. Also, several input data constructs simply aren't allowed by the specs, and that may cause a different transfer-encoding to get used instead. And by established rules + popular demand, every occurrence of ‘^From_’ (peepmbox-rfc4155) gets MBOXO quoted — that means prefixed with the greater-than sign ‘>’ — instead of triggering a non-destructive encoding like ‘quoted-printable’, unless the context (like message signing) requires otherwise. Context is the main character here, fr fr.quoted-printable(orqp) — this one is 7-bit clean and has the cutest property ever: ASCII characters pass through completely unchanged, so an English message is readable as-is 🫶. It's also fine for other single-byte locales that share lots of characters with ASCII, for example ISO-8859-1. But the overhead for messages in other character sets? Ouch. It'll need up to twelve (12) bytes to encode a single UTF-8 character of four (4) bytes 😭. It is the default encoding, so it's what you're getting unless you say otherwise.base64(orb64) — 7-bit clean, and it will always be used for binary data, periodt. The ratio is constant at 3:4, meaning no matter what the character set of the input data is, it encodes three bytes of input into four bytes of output. Downside? This transfer-encoding is not human readable unless you do a decoding step. It's giving secret code 🔥.
mime-force-sendout
(Boolean) [Option] So like — whenever it's simply not acceptable to fail sending out messages because of non-convertible character content, you're allowed to set this variable 💖. As an absolute last resort, it will classify the part content as ‘application/octet-stream’. For the whole picture on character set conversion, go read the section “Character sets”, and for how to internally or externally handle part content, the section “HTML mail and MIME attachments” has you covered.
mimetypes-load-control
This one controls which of “The mime.types files” get loaded, and the vibe is letter-based:
- if the letter ‘u’ is part of the option value, then your personal
~/.mime.typesfile gets loaded (that is, if it exists at all) - likewise, the letter ‘s’ controls loading of the system wide
/etc/mime.types - directives found in the user file take precedence, and letter matching is case-insensitive, okay bestie?
- if this variable is not set, S-nail will try to load both files
Incorporation of the S-nail-built-in MIME types cannot be suppressed, but they will be matched last (and the order can be listed via mimetype, so you can go check 👀).
More sources can be specified with a different syntax: if the value string contains an equals sign ‘=’, then it's instead parsed as a comma-separated list of those letters we just talked about, plus ‘f=FILENAME’ pairs 🎀. The given filenames will be expanded and loaded, and their content may use the extended syntax described in the section “The mime.types files”. Directives found in such files always take precedence — they are prepended to the MIME type cache, no cap.
mta
Pick an alternate Mail-Transfer-Agent by either specifying the full pathname of an executable (a ‘file://’ prefix may be given, cute), or [Option]ally a SMTP aka SUBMISSION protocol URL [v15-compat]:
submissions://[user[:password]@]server[:port]
([no v15-compat]: ‘[smtp://]server[:port]’.) The default was chosen at compile time, so blame the builders 💀. MTA data transfers are always performed in asynchronous child processes, and without supervision unless either the sendwait or the verbose variable is set. Also see mta-bcc-ok. [Option]ally, expansion of aliases(5) can be performed by setting mta-aliases.
For testing purposes there's the ‘test’ pseudo-MTA, which dumps to standard output or optionally to a file, and honours mbox-fcc-and-pcc:
$ echo text | s-nail -:/ -Smta=test -s ubject ex@am.ple
$ </dev/null s-nail -:/ -Smta=test://./xy ex@am.ple
For a file-based MTA it may be necessary to set mta-argv0 in in order to choose the right target of a modern mailwrapper(8) environment. It will be passed command line arguments from several possible sources: from the variable mta-arguments if set, and from the command line if given and the variable expandargv allows their use. Argument processing of the MTA will be terminated with a -- separator, periodt.
The otherwise occurring implicit usage of the following MTA command line arguments can be disabled by setting the boolean variable mta-no-default-arguments (which will also disable passing -- to the MTA):
-i(for not treating a line with only a dot ‘.’ character as the end of input)-m(shall the variablemetoobe set)-v(if theverbosevariable is set)
and in conjunction with the -r command line option or r-option-implicit, -f as well as possibly -F will (not) be passed. Iykyk 🌸.
[Option]ally, S-nail can send mail over SMTP aka SUBMISSION network connections to a single defined smart host by setting this variable to a SMTP or SUBMISSION URL (see “On URL syntax and credential lookup”). An authentication scheme can be specified via the variable chain smtp-auth. Encrypted network connections are [Option]ally available, and the section “Encrypted network communication” should give an overview plus links to more info on that 🔐. Note that with some mail providers it may be necessary to set the smtp-hostname variable in order to use a specific combination of from, hostname and mta. Network communication socket timeouts are configurable via socket-connect-timeout. All generated network traffic may be proxied over a SOCKS socks-proxy, and it can be logged by setting verbose twice. The following SMTP variants may be used:
- The plain SMTP protocol (RFC 5321) that normally lives on the server port 25 and requires setting the
smtp-use-starttlsvariable to enter a TLS encrypted session state. Assign a value like [v15-compat] ‘smtp://[user[:password]@]server[:port]’ ([no v15-compat] ‘smtp://server[:port]’) to choose this protocol. - The so-called SMTPS, which is supposed to live on server port 465 and is automatically TLS secured. Unfortunately it never became a standardized protocol and may thus not be supported by your hosts network service database — in fact the port number has already been reassigned to other protocols! 😭
SMTPS is nonetheless a commonly offered protocol and thus can be chosen by assigning a value like [v15-compat] ‘smtps://[user[:password]@]server[:port]’ ([no v15-compat] ‘smtps://server[:port]’); due to the mentioned problems it is usually necessary to explicitly specify the port as ‘:465’, however.
- The SUBMISSION protocol (RFC 6409) lives on server port 587 and is identically to the SMTP protocol from S-nail's point of view; it requires setting
smtp-use-starttlsto enter a TLS secured session state; e.g., [v15-compat] ‘submission://[user[:password]@]server[:port]’. - The SUBMISSIONS protocol (RFC 8314) that lives on server port 465 and is TLS secured by default 💅. It can be chosen by assigning a value like [v15-compat] ‘submissions://[user[:password]@]server[:port]’. Due to the problems mentioned for SMTPS above and the fact that SUBMISSIONS is new and a successor that lives on the same port as the historical engineering mismanagement named SMTPS, it is usually necessary to explicitly specify the port as ‘:465’.
mta-aliases
[Option] If set to a path pointing to a text file in valid MTA (Postfix) aliases(5) format, the file is loaded and cached (manageable with mtaaliases, bestie), and henceforth plain ‘name’ (see expandaddr) message receiver names are recursively expanded as a last expansion step, after the distribution lists which can be created with alias. Constraints on aliases(5) content support, listen up:
- only local addresses (names) which are valid usernames (‘
[a-z_][a-z0-9_-]*[$]?’) are treated as expandable aliases - and [v15 behaviour may differ] ‘:include:/file/name’ directives are not supported, sorry not sorry 🙈
By including ‘-name’ in expandaddr it can be asserted that only expanded names (mail addresses) are passed through to the MTA. Clean. 🎀
mta-arguments
Arguments to pass through to a file-based mta (Mail-Transfer-Agent), parsed according to “Shell-style argument quoting” into an array of arguments which will be joined onto MTA options from other sources, for example ‘? wysh set mta-arguments='-t -X "/tmp/my log"'’ ✨.
mta-no-default-arguments
(Boolean) Avoids passing standard command line options to a file-based mta — please see there 👑.
mta-no-receiver-arguments
Boolean 💖 — the default vibe is that all receiver addresses get passed as command line options to a file-based mta. Setting this variable disables that behaviour, to help out those MTAs that do special treatment of such arguments. But heads up bestie: doing this can make it necessary to pass a -t via mta-arguments, to testify to the MTA that it should use the passed message as a template. 🫶
mta-argv0
So many systems use a mailwrapper(8) environment to keep compatibility with sendmail(1). It works by inspecting the name that was used to invoke the mail delivery system. If this variable is set, then the mailwrapper (the program that's actually executed when you call the file-based mta) will treat its contents as that name. 👑
mta-bcc-ok
Boolean 🫢 — in violation of RFC 5322, some MTAs just do not remove 'Bcc:' header lines from transported messages after having noted the respective receivers for addressing purposes. (The MTAs Exim and Courier for example require the command line option -t to enforce removal.) Unless this is set, corresponding receivers are addressed by protocol-specific means or MTA command line options only, and the header itself is stripped before being sent over the wire. 💅
netrc-lookup-USER@HOST, netrc-lookup-HOST, netrc-lookup
Boolean[v15-compat][Option] 🎀 — controls the usage of the user's ~/.netrc file for lookup of account credentials, as documented in the section "On URL syntax and credential lookup" and for the command netrc; the section "The .netrc file" documents the file format. Also see netrc-pipe.
netrc-pipe
[v15-compat][Option] ✨ — when ~/.netrc is loaded (see netrc and netrc-lookup) then S-nail will read the output of a shell pipe instead of the user's ~/.netrc file, if this variable is set (to the desired shell command). You can use this to, for example, store ~/.netrc in encrypted form:
? set netrc-pipe='gpg -qd ~/.netrc.pgp'
newfolders
[Option] 🦋 — if this variable has the value maildir, newly created local folders will be in Maildir instead of MBOX format.
newmail
Checks for new mail in the current folder every single time the prompt is shown. A Maildir folder must be re-scanned to determine if new mail has arrived. If this variable is set to the special value nopoll then a Maildir folder will not be rescanned completely — only timestamp changes are detected. Maildir folders are [Option]al. 🙈
outfolder
Boolean 🌸 — causes a non-absolute filename specified in record, as well as the sender-based filenames of the Copy, Save, Followup and followup commands, to be interpreted relative to the folder directory rather than relative to the current directory.
on-account-cleanup-ACCOUNT, on-account-cleanup
Macro hook which will be called once an account is left, as the very last step before unrolling per-account localopts. 💜 This hook is run even in case of fatal errors, including those generated by switching to the account as such, and it is advisable to perform only absolutely necessary actions, like cleaning up alternates, for example. The specialized form is used in favour of the generic one if found.
on-compose-cleanup
Macro hook which will be called after the message has been sent (or not, in case of failures), as the very last step before unrolling compose mode localopts. This hook is run even in case of fatal errors, and it is advisable to perform only absolutely necessary actions, like cleaning up alternates, for example. ⭐
For compose mode hooks that may affect the message content please see on-compose-enter, on-compose-leave, on-compose-splice.
[v15 behaviour may differ] This hook exists because alias, alternates, commandalias, shortcut, to name a few, are neither covered by localopts nor by local: — changes applied in compose mode will continue to be in effect thereafter. 😭
on-compose-enter, on-compose-leave
Macro hooks which will be called once compose mode is entered, and after composing has been finished, respectively; the exact order of the steps taken is documented for ~., one of the "COMMAND ESCAPES". Context about the message being worked on can be queried via digmsg. localopts are enabled for these hooks, and changes on variables will be forgotten after the message has been sent. on-compose-cleanup can be used to perform other necessary cleanup steps. 🧚
Here is an example that injects a signature via message-inject-tail; instead using on-compose-splice to simply inject the file of desire via ~< or ~<! may be a better approach.
define t_ocl {
vput ! i cat ~/.mysig
if $? -eq 0
vput csop message-inject-tail trim-end $i
end
# Alternatively
readctl create ~/.mysig
if $? -eq 0
readall i
if $? -eq 0
vput csop message-inject-tail trim-end $i
end
readctl remove ~/.mysig
end
}
set on-compose-leave=t_ocl
on-compose-splice, on-compose-splice-shell
These hooks run once the normal compose mode is finished, but before the on-compose-leave macro hook is called etc. Both hooks will be executed in a subprocess, with their input and output connected to S-nail such that they can act as if they would be an interactive user. 🔥 The difference in between them is that the latter is a SHELL command, whereas the former is a normal defined macro, but which is restricted to a small set of commands (the verbose output of for example list will indicate said capability). localopts are enabled for these hooks (in the parent process), causing any setting to be forgotten after the message has been sent; on-compose-cleanup can be used to perform other cleanup as necessary.
During execution of these hooks S-nail will temporarily forget whether it has been started in interactive mode, (a restricted set of) "COMMAND ESCAPES" will always be available, and for guaranteed reproducibilities sake escape and ifs will be set to their defaults. The compose mode command ~^ has been especially designed for scriptability (via these hooks). The first line the hook will read on its standard input is the protocol version of said command escape, currently 0 0 2 — backward incompatible protocol changes have to be expected. 💀
Care must be taken to avoid deadlocks and other false control flow: if both involved processes wait for more input to happen at the same time, or one does not expect more input but the other is stuck waiting for consumption of its output, etc. There is no automatic synchronization of the hook: it will not be stopped automatically just because it, e.g., emits ~x. The hooks will however receive a termination signal if the parent enters an error condition.
[v15 behaviour may differ] Protection against and interaction with signals is not yet given; it is likely that in the future these scripts will be placed in an isolated session, which is signalled in its entirety as necessary. 🙏
define ocs_signature {
read version
echo '~< ~/.mysig' # '~<! fortune pathtofortunefile'
}
set on-compose-splice=ocs_signature
wysh set on-compose-splice-shell=$'\
read version;\
printf "hello $version! Headers: ";\
echo \'~^header list\';\
read status result;\
echo "status=$status result=$result";\
'
define ocsm {
read version
echo Splice protocol version is $version
echo '~^h l'; read hl; vput csop es subs "${hl}" 0 1
if "$es" != 2
echoerr 'Cannot read header list'; echo '~x'; xit
endif
if "$hl" !%?case ' cc'
echo '~^h i cc "Diet is your <mirr.or>"'; read es;\
vput csop es substring "${es}" 0 1
if "$es" != 2
echoerr 'Cannot insert Cc: header'; echo '~x'
# (no xit, macro finishes anyway)
endif
endif
}
set on-compose-splice=ocsm
on-history-addition
This hook will be called if an entry is about to be added to the history of the MLE, as documented in "On terminal control and line editor". 🌈 It will be called with three arguments: the first is the name of the input context (see bind), the second is either an empty string or the matching history-gabby type, and the third being the complete command line to be added. The entry will not be added to history if the hook uses a non-0 return. [v15 behaviour may differ] A future version will give the expanded command name as the third argument, followed by the tokenized command line as parsed in the remaining arguments, the first of which is the original unexpanded command name; i.e., one may do shift 4 and will then be able to access the positional parameters as usual via *, #, 1 etc.
on-main-loop-tick
This hook will be called whenever the program's main event loop is about to read the next input line. 👑 Note variable and other changes it performs are not scoped as via localopts! 🙈
on-program-exit— this hook gets called when the program exits, periodt 💅 whether that's viaexitorquit, or because the send mode is done. but bestie, heads up: it runs late, so terminal settings etc. are already torn down by the time it fires. 💀on-resend-cleanup— [v15 behaviour may differ] literally identical toon-compose-cleanup, except it's only triggered by resend. same energy, different trigger. 🔁on-resend-enter— [v15 behaviour may differ] literally identical toon-compose-enter, except it's only triggered by resend; rn there's nodigmsgsupport, for example. 🫶page— (Boolean) if you set this, every message that gets fed through the command you gave for pipe gets followed by a formfeed character\f. 🎀password-USER@HOST,password-HOST,password— [v15-compat] this is the variable chain that sets a password 💖 it gets used when none was given in the protocol and the account-specific URL; and as a literal last resort, S-nail will just ask you for a password on your terminal if the authentication method needs one.
specifying passwords in a startup file is generally a security risk, fr fr — that file should be readable by the invoking user only. 🔒
password-USER@HOST— [no v15-compat] (see the chain above for [v15-compat]) use this to set the password for ‘USER’ when you connect to ‘HOST’. if there's no such variable defined for a host, the user gets asked for a password on standard input instead. 💌
again: putting passwords in a startup file is generally a security risk, and that file should be readable by the invoking user only. no cap. 🙈
piperaw— (Boolean) sends messages to the pipe command without doing MIME and character set conversions. raw and unfiltered, iykyk. ✨pipe-EXTENSION— identical topipe-TYPE/SUBTYPE, except ‘EXTENSION’ (normalized to lowercase using character mappings of the ASCII charset) means a file extension — think ‘xhtml’. 🌸 and yes, handlers you register this way take precedence. 👑pipe-TYPE/SUBTYPE— a MIME message part identified as ‘TYPE/SUBTYPE’ (case-insensitive, normalized to lowercase using character mappings of the ASCII charset) is displayed or quoted, and its text gets filtered through the value of this variable, which is interpreted as a shell command. 🐚 unless noted, only parts that are displayable as inline plain text (seecopiousoutput) are covered — other MIME parts will only be considered by and formimeview.
the special value question mark ‘?’ forces interpretation of the message part as plain text — like set pipe-application/xml=? for example. (you can also pull this off by adding a MIME type-marker via mimetype.) *[Option]*ally, MIME type handlers may be defined via “The Mailcap files”, which you should go read for documentation of flags like copiousoutput. the question mark is genuinely a trigger character that says "the rest of this value has flags that adjust behaviour and usage" — and then comes the shell command. for example:
? set pipe-X/Y='?!++=? vim ${MAILX_FILENAME_TEMPORARY}'
- ‘*’ — the command output can be reintegrated into this MUA's normal processing:
copiousoutput. it's implied when you use a plain ‘’. - ‘#’ — only use this handler for display, not for quoting a message:
x-mailx-noquote. - ‘&’ — run the command asynchronously, don't wait for the handler to exit:
x-mailx-async. the standard output of the command will go to/dev/null. 💀 - ‘!’ — the command must be run on an interactive terminal, so the terminal gets temporarily released for it to run:
needsterminal. - ‘+’ — request creation of a zero-sized temporary file, whose absolute pathname will be made accessible via the environment variable
MAILX_FILENAME_TEMPORARY:x-mailx-tmpfile. if you give it twice, then the file will be unlinked automatically by S-nail when the command loop is entered again at the latest:x-mailx-tmpfile-unlink. 🧚 and yes — it is an error to use automatic deletion in conjunction withx-mailx-async. 🚨 - ‘=’ — normally the MIME part content is passed to the handler via standard input; with this, the data gets written into
MAILX_FILENAME_TEMPORARYinstead (x-mailx-tmpfile-fill), and the creation of it is implied. but to cause automatic deletion of that temporary file, you still have to use two plus signs ‘++’. 🔥 - ‘t’ — text type-marker: display this as normal plain text (for type-markers see “The mime.types files”). identical to just giving a plain ‘?’, and it implies
copiousoutput. - ‘h’ — [Option] HTML type-marker: display via the built-in HTML-to-text filter. implies
copiousoutput. 🎀 - ‘?’ — to avoid ambiguities with normal shell command content, you can use another question mark to forcefully terminate interpretation of the remaining characters. (any character that's not in this list will have the exact same effect, bestie.) 💅
some info about the MIME part that's about to be displayed gets embedded into the environment of the shell command:
MAILX_CONTENT— the MIME content-type of the part, if known, and the empty string otherwise.MAILX_CONTENT_EVIDENCE— ifmime-counter-evidenceincludes the carry-around-bit (2), then this gets set to the detected MIME content-type; otherwise it's identical toMAILX_CONTENT, not only then. ⭐MAILX_EXTERNAL_BODY_URL— MIME parts of type ‘message/external-body access-type=url’ will store the access URL in this variable, and it's empty otherwise.
URL targets should not be activated automatically, without supervision. 🚩
MAILX_FILENAME— the filename, if any is set, and the empty string otherwise.MAILX_FILENAME_GENERATED— a random string. 🎲MAILX_FILENAME_TEMPORARY— if temporary file creation has been requested through the command prefix, this variable will be set and contain the absolute pathname of the temporary file.
pop3-auth-USER@HOST,pop3-auth-HOST,pop3-auth— [Option]*[v15-compat]* the variable chain that sets the POP3 authentication method. 🦋 supported are the default ‘plain’, [v15-compat] ‘oauthbearer’ (see the “FAQ” entry “But, how about XOAUTH2 / OAUTHBEARER?”), plus [v15-compat] ‘external’ and ‘externanon’ for TLS secured connections that pass a client certificate viatls-config-pairs. there may also be the [Option]al method [v15-compat] ‘gssapi’. ‘externanon’ doesn't need any user credentials at all, while ‘external’ and ‘gssapi’ need a user, and the rest also require a password. ‘externanon’ solely builds upon the credentials passed via a client certificate, and is usually the way to go, since the tested servers do not actually follow RFC 4422, and fail if additional credentials are actually passed. 👑 and unlesspop3-no-apopis set, the ‘plain’ method will *[Option]*ally be replaced with APOP if possible (see there). ✨pop3-bulk-load-USER@HOST,pop3-bulk-load-HOST,pop3-bulk-load— (Boolean)*[Option]* when accessing a POP3 server, S-nail loads the headers of the messages, and only requests the message bodies on user request. for the POP3 protocol this means the message headers will be downloaded twice. 💀 if this variable is set, then S-nail will download only complete messages from the given POP3 server(s) instead. 🍓pop3-keepalive-USER@HOST,pop3-keepalive-HOST,pop3-keepalive— [Option] POP3 servers close the connection after a period of inactivity; the standard requires this to be at least 10 minutes, but practical experience may vary. 😭 setting this variable to a numeric value greater than ‘0’ causes a ‘NOOP’ command to be sent each value seconds if no other operation is performed. 💜pop3-no-apop-USER@HOST,pop3-no-apop-HOST,pop3-no-apop— (Boolean)*[Option]* unless this variable is set, the MD5 based ‘APOP’ authentication method will be used instead of a chosen ‘plain’pop3-authwhen connecting to a POP3 server that advertises support. the advantage of ‘APOP’ is that only a single packet is sent for the user/password tuple. (originally also that the password is not sent in clear text over the wire, but for one, MD5 does not any longer offer sufficient security, and then today transport is almost ever TLS secured.) note thatpop3-no-apop-HOSTrequires [v15-compat]. 🌈pop3-use-starttls-USER@HOST,pop3-use-starttls-HOST,pop3-use-starttls— (Boolean)*[Option]* causes S-nail to issue a ‘STLS’ command to make an unencrypted POP3 session TLS encrypted. 🔒 this functionality is not supported by all servers, and is not used if the session is already encrypted by the POP3S method. note thatpop3-use-starttls-HOSTrequires [v15-compat].posix— (Boolean) this flag enables POSIX mode, which changes behaviour of S-nail wherever that deviates from standardized behaviour. 👑 it's automatically squared with the environment variablePOSIXLY_CORRECT— change one and the other gets adjusted too. the following behaviour is covered and enforced by this mechanism:
okay bestie, breathing through the last of the compatibility tea, then it's straight back into variables — you're doing amazing 🫶
- In non-interactive mode, any error encountered while loading resource files during program startup will cause a program exit, whereas in interactive mode such errors will stop loading of the currently loaded (stack of) file(s, i.e., recursively). These exits can be circumvented on a per-command base by using
ignerr, one of the “Command modifiers”, for each command which shall be allowed to fail. alternateswill replace the list of alternate addresses instead of appending to it. In additionalternateswill only be honoured for any sort of message reply, and for aliases.- The variable inserting “COMMAND ESCAPES”
~A,~a,~Iand~iwill expand embedded character sequences'\t'horizontal tabulator and'\n'line feed. [v15 behaviour may differ] For compatibility reasons this step will always be performed. - Reading in messages via
~f(“COMMAND ESCAPES”) will use thetypenot theforwardheaderpick selection. - Upon changing the active folder no summary of headers will be displayed even if
headeris set. - Setting
ignoreeofimplies the behaviour described bydot. - The variable
keepis extended to cover any empty mailbox, not only empty “primary system mailbox”es: they will be removed when they are left in empty state otherwise. - Each command has an exit
?and error!status that overwrites that of the last command. In POSIX mode the program exit status will signal failure regardless unless all messages were successfully sent out to the mta; also seesendwait.
print-alternatives 🦋
(Boolean) When a MIME message part of type multipart/alternative is displayed and it contains a subpart of type text/plain, other parts are normally discarded. Setting this variable causes all subparts to be displayed, just as if the surrounding part was of type multipart/mixed.
prompt ✨
The string used as a prompt in interactive mode. Whenever the variable is evaluated the value is treated as if specified within dollar-single-quotes (see “Shell-style argument quoting”). This (post-assignment, i.e., second) expansion can be used to embed status information, for example ?, !, account or mailbox-display.
In order to embed characters which should not be counted when calculating the visual width of the resulting string, enclose the characters of interest in a pair of reverse solidus escaped brackets: '\[\E[0m\]'; a slot for coloured prompts is also available with the [Option]al command colour. Prompting may be prevented by setting this to the null string (aka set noprompt).
prompt2 🎀
This string is used for secondary prompts, but is otherwise identical to prompt. The default is '.. '.
quiet 🙈
(Boolean) Suppresses the printing of the version when first invoked.
quote 💅
If set messages processed by variants of followup and reply will start with the original message, lines of which prefixed by indentprefix, taking into account quote-chars and quote-fold. No headers will be quoted when set without value or for 'noheading', for 'headers' the type headerpick selection will be included in the quote, 'allbodies' embeds the (body) contents of all MIME parts, and 'allheaders' also includes all headers. The quoted message will be enclosed by the expansions of quote-inject-head and quote-inject-tail. Also see quote-add-cc, quote-as-attachment and ~Q, one of the “COMMAND ESCAPES”.
quote-add-cc 🌸
(Boolean) Whether senders of messages quoted via ~Q shall be made members of the carbon copies Cc: list.
quote-as-attachment 📎
(Boolean) Add the original message in its entirety as a message/rfc822 MIME attachment when replying to a message. Note this works regardless of the setting of quote.
quote-chars 🧚
Can be set to a string consisting of non-whitespace ASCII characters which shall be treated as quotation leaders, the default being '>|}:'.
quote-fold 🌀
[Option] Can be set in addition to indentprefix, and creates a more fancy quotation in that leading quotation characters (quote-chars) are compressed and overlong lines are folded. quote-fold can be set to either one, two or three (space separated) numeric values, which are interpreted as the maximum (goal) and the minimum line length, respectively, in a spirit rather equal to the fmt(1) program, but line- instead of paragraph-based. The third value is used as the maximum line length instead of the first if no better break point can be found; it is ignored unless it is larger than the minimum and smaller than the maximum. If not set explicitly the minimum will reflect the goal algorithmically. The goal cannot be smaller than the length of indentprefix plus some additional pad; necessary adjustments take place silently.
quote-inject-head, quote-inject-tail 💌
The strings to put before and after the text of a quoted message, if non-empty, and respectively. The former defaults to '%f wrote:\n\n'. Special format directives will be expanded if possible, and if so configured the output will be folded according to quote-fold. Format specifiers in the given strings start with a percent sign '%' and expand values of the original message, unless noted otherwise. Note that names and addresses are not subject to the setting of showto. Valid format specifiers are:
'%%'— A plain percent sign.'%a'— The address(es) of the sender(s).'%d'— The date found in theDate:header of the message whendatefieldis set (the default), otherwise the date when the message was received. Formatting can be controlled by assigning a strftime(3) format string todatefield(anddatefield-markout-older).'%f'— The full name(s) (name and address, as given) of the sender(s).'%i'— TheMessage-ID:.'%n'— The real name(s) of the sender(s) if there is one andshownameallows usage, the address(es) otherwise.'%r'— The senders real name(s) if there is one, the address(es) otherwise.
r-option-implicit 🍓
(Boolean) Setting this option evaluates the contents of from (or, if that contains multiple addresses, sender) and passes the results onto the used (file-based) MTA as described for the -r option (empty argument case).
recipients-in-cc 👑
(Boolean) When doing a reply, the original From: and To: as well as addressees which possibly came in via Reply-To: and Mail-Followup-To: are by default merged into the new To:. If this variable is set a sensitive algorithm tries to place in To: only the sender of the message being replied to, others are placed in Cc:.
record 📼
Unless this variable is defined, no copies of outgoing mail will be saved. If defined it gives the pathname, subject to the usual “Filename transformations”, of a folder where all new, replied-to or forwarded messages are saved: when saving to this folder fails the message is not sent, but instead saved to DEAD. The standard defines that relative (fully expanded) paths are to be interpreted relative to the current directory (cwd), to force interpretation relative to folder outfolder needs to be set in addition.
record-files 📁
(Boolean) If this variable is set the meaning of record will be extended to cover messages which target only file and pipe recipients (see expandaddr). These address types will not appear in recipient lists unless add-file-recipients is also set.
record-resent 🔁
(Boolean) If this variable is set the meaning of record will be extended to also cover the resend and Resend commands.
reply-in-same-charset 🌈
(Boolean) If this variable is set S-nail first tries to use the same character set of the original message for replies. If this fails, the mechanism described in “Character sets” is evaluated as usual.
reply-strings ⭐
Can be set to a comma-separated list of (case-insensitive according to ASCII rules) strings which shall be recognized in addition to the built-in strings as Subject: reply message indicators – built-in are 'Re:', which is mandated by RFC 5322, as well as the german 'Aw:', 'Antw:', and the 'Wg:' which often has been seen in the wild; I.e., the separating colon has to be specified explicitly.
reply-to 💖
A list of addresses to put into the Reply-To: field of the message header. Members of this list are handled as if they were in the alternates list.
replyto 💀
[Obsolete] Variant of reply-to.
reply-to-honour 🫶
Controls whether a Reply-To: header is honoured when replying to a message via reply or Lreply. This is a “quadoption”; if set without a value it defaults to “yes”.
reply-to-swap-in— so here's the ✨tea✨: standards like DKIM and (in cahoots with) DMARC made a ton of "Mailing lists" start doing sender address rewriting like ‘Name via List <list@address>’, where your actual original sender address gets yeeted into theReply-To:header instead. If this variable is set and aReply-To:exists, and it has only one addressee (!), then that addressee gets used instead of the pretend-sender. This works totally independently ofreply-to-honour, no cap. The optional value is a comma-separated list of strings for more fine-grained control over when the swap happens; rn the only supported one ismlist, and swapping kicks in if the sender is a mailing-list as defined bymlist.rfc822-body-from_— (Boolean) Lets you force displaying a so-called ‘From_’ line for messages that are embedded into an envelope mail via themessage/rfc822MIME mechanism, just for more visual convenience 💅. Also peepmbox-rfc4155.save— (Boolean) Enables saving of (partial) messages inDEADwhen there's an interrupt or delivery error. Protect your progress bestie 🫶.screen— the number of lines that counts as a "screenful" of lines. Used in the headers summary display, when searching, in message topline display, and when scrolling withz. If this variable isn't set, S-nail falls back to a calculation based on your detected terminal window size and the baud rate — the faster the terminal, the more it'll show 🚀. Overall screen dimensions and pager usage are influenced by the environment variablesCOLUMNSandLINESand the variablecrt.searchheaders— (Boolean) Expands message list specifiers shaped like ‘/x:y’ to all messages containing the substring "y" in the header field x. And the string search is case insensitive, so don't stress about caps 🔍.sendcharsets— [Option] A comma-separated list of character set names that can be used in outgoing internet mail. The value of the variablecharset-8bitis automatically appended to this list. If no character set conversion capabilities are compiled into S-nail, then the only supported charset isttycharset. Also go look atsendcharsets-else-ttycharset, and check the section "Character sets" for the whole picture of character set conversion in S-nail 🌈.sendcharsets-else-ttycharset— (Boolean)[Option] If this variable is set, butsendcharsetsis not, then S-nail acts as ifsendcharsetshad been set to the value of the variablettycharset. In effect, this combo passes the message data straight through in the character set of the current locale encoding: so mail message text will be (assumed to be) in ISO-8859-1 encoding when sent from within an ISO-8859-1 locale, and in UTF-8 encoding when sent from within a UTF-8 locale.
The 8-bit fallback charset-8bit never comes into play here, because ttycharset is implicitly assumed to be 8-bit and capable of representing all files the user may specify (same as when no character set conversion support is available in S-nail and the only supported character set is ttycharset, see "Character sets"). This might be a problem for scripts which use the suggested LC_ALL=C setting, since in that case the character set is US-ASCII by definition, so it's better to also override ttycharset, then; and/or do something like the following in the resource file:
# Avoid ASCII "propagates to 8-bit" when scripting
\if ! t && "$LC_ALL" != C && "$LC_CTYPE" != C
\set sendcharsets-else-ttycharset
\end
sender— an address that gets put into theSender:field of outgoing messages. Quoting RFC 5322: the mailbox of the agent responsible for the actual transmission of the message. This field should normally not be used unless the from field contains more than one address, in which case it is required.[v15 behaviour may differ]Please expect automatic management of the from and sender relationship. Depending on the context, this address is handled as if it were in the list of alternates. Also see-r,r-option-implicit.sendmail—[Obsolete]Predecessor ofmta.sendmail-arguments—[Obsolete]Predecessor ofmta-arguments.sendmail-no-default-arguments—[Obsolete](Boolean) Predecessor ofmta-no-default-arguments.sendmail-progname—[Obsolete]Predecessor ofmta-argv0.sendwait— sending messages to the chosen mta or to command-pipe receivers (see "On sending mail, and non-interactive mode") will be performed asynchronously. Which means only startup errors of the respective program will be recognizable, but no delivery errors 😭. Also, no guarantees can be made as to when the respective program will actually run, or as to when it will have produced output.
If this variable is set, then the child program's exit is waited for, and its exit status code is used to decide about success. Remarks: in conflict with the POSIX standard, this variable is built-in to be initially set. Another difference is that it can have a value, which is interpreted as a comma-separated list of case-insensitive strings naming specific subsystems for which synchronousness shall be ensured (only). Possible values are mta for mta delivery, and pcc for command-pipe receivers ⏳.
showlast— (Boolean) Makes S-nail start at the last message instead of the first one when opening a mail folder, and same withfromandheaders. Skip to the end bestie 👑showname— (Boolean) Makes S-nail use the sender's real name instead of the plain address in the header field summary and in message specifications.showto— (Boolean) Makes the recipient of the message get shown in the header summary if the message was sent by the user.Sign— the value backing~A, one of the "COMMAND ESCAPES". Also seemessage-inject-tail,on-compose-leaveandon-compose-splice.sign— the value backing~a, one of the "COMMAND ESCAPES". Also seemessage-inject-tail,on-compose-leaveandon-compose-splice.signature—[Obsolete]Please useon-compose-spliceoron-compose-splice-shelloron-compose-leaveand (if necessary)message-inject-tailinstead!skipemptybody— (Boolean) If an outgoing message has an empty first or only message part, don't send it — discard it, successfully 💀 (also see the command line option-E).smime-ca-dir,smime-ca-file— [Option] Specify the location of trusted CA certificates in PEM (Privacy Enhanced Mail) for the purpose of verification of S/MIME signed messages.tls-ca-dirdocuments the necessary preparation steps to use the former. The set of CA certificates which are built into the TLS library can be explicitly turned off by settingsmime-ca-no-defaults, and further fine-tuning is possible viasmime-ca-flags.smime-ca-flags— [Option] Can be used to fine-tune behaviour of the X509 CA certificate storage, and the certificate verification that's used. The actual values and their meanings are documented fortls-ca-flags.smime-ca-no-defaults— (Boolean)[Option] Do not load the default CA locations that are built into the used TLS library to verify S/MIME signed messages.smime-cipher-USER@HOST,smime-cipher— [Option] Specifies the cipher to use when generating S/MIME encrypted messages (for the specified account). RFC 5751 mandates a default ofaes128(AES-128 CBC). Possible values are (case-insensitive and) in decreasing cipher strength:aes256(AES-256 CBC),aes192(AES-192 CBC),aes128(AES-128 CBC),des3(DES EDE3 CBC, 168 bits; default ifaes128is not available) anddes(DES CBC, 56 bits).
The actually available cipher algorithms depend on the cryptographic library that S-nail uses. [Option] Support for more cipher algorithms may be available through dynamic loading via EVP_get_cipherbyname(3) (OpenSSL) if S-nail has been compiled to support this 🔐.
smime-crl-dir— [Option] Specifies a directory that contains files with CRLs in PEM format to use when verifying S/MIME messages.smime-crl-file— [Option] Specifies a file that contains a CRL in PEM format to use when verifying S/MIME messages.smime-encrypt-USER@HOST— [Option] If this variable is set, messages sent to the given receiver are encrypted before sending. The value of the variable must be set to the name of a file that contains a certificate in PEM format 🎀.
If a message is sent to multiple recipients, each of them for whom a corresponding variable is set will receive an individually encrypted message; other recipients will continue to receive the message in plain text unless the smime-force-encryption variable is set. It's recommended to sign encrypted messages, i.e., to also set the smime-sign variable. content-description-smime-message will be inspected for messages which become encrypted.
smime-force-encryption— (Boolean)[Option] Causes S-nail to refuse sending unencrypted messages. No plaintext leaks, periodt 🔥.
smime-sign
[Boolean] [Option] — okay so this one makes S-nail S/MIME sign everything you send out, using your from private key, and it tacks your certificate onto the message as a MIME attachment. ✨
And like… why do we care? Because it lets the person receiving it verify three iconic things: that the sender used a valid certificate, that the email addresses in the certificate match the ones in the message header, and that the message content has not been altered. That's the whole point, no cap.
The best part? It does not change the message text at all. People still read your message like a normal message. Nothing changes on their end. 🫶
content-description-smime-signature will be inspected. Also go look at smime-sign-cert, smime-sign-include-certs and smime-sign-digest — they're the friend group.
smime-sign-cert-USER@HOST, smime-sign-cert
[Option] — this points at a file in PEM format. And for signing and decryption purposes, that file needs to contain the user's private key, followed by their certificate. In that order. Bestie, order matters, don't freestyle it. 🎀
For message signing, USER@HOST is always derived from the value of from — or, if from contains multiple addresses, from sender. For encryption, what's expected is the recipient's public encryption key (certificate); the certsave command can be used to save certificates of signed messages (the section "Signed and encrypted messages with S/MIME" spills some tea on that). This mode of operation is usually driven by the specialized form.
When you're decrypting messages, the account gets derived from the recipient fields — To: and Cc: — of the message, which get searched for addresses that have such a variable set. Heads up: S-nail always uses the first address that matches. So if the same message is sent to more than one of your addresses and they use different encryption keys, decryption might fail. 😭 Not a bug, just how it goes.
Password-encrypted keys may be used for signing and decryption. Automated password lookup is possible via the "pseudo-hosts" USER@HOST.smime-cert-key for the private key, and USER@HOST.smime-cert-cert for the certificate stored in the same file. For example, the hypothetical address bob@exam.ple could be driven with a private key / certificate pair path defined in smime-sign-cert-bob@exam.ple, and the needed passwords would then be looked up as bob@exam.ple.smime-cert-key and bob@exam.ple.smime-cert-cert. Lowkey elegant. 💅
When decrypting, the value of from will be tried as a fallback to supply the necessary USER@HOST. To include intermediate certificates, use smime-sign-include-certs. The possible password sources are documented in "On URL syntax and credential lookup".
smime-sign-digest-USER@HOST, smime-sign-digest
[Option] — this one picks the message digest used when signing S/MIME messages. 🦋 Remember that for this use case USER@HOST refers to the variable from (or, if that contains multiple addresses, sender).
The algorithms you can actually pick from depend on the cryptographic library in play, but at least one usable built-in algorithm is ensured as a default, so you're never left with nothing. And if possible, the standard RFC 5751 will be violated on purpose — by using SHA512 instead of the mandated SHA1 — because, security concerns, obviously. We're not doing that.
This variable is ignored for very old cryptographic libraries (released before 2010) which don't offer the necessary interface. If that happened, it will be logged. So check your logs if something's looking sus.
S-nail will try to add built-in support for the following message digests — and the names are case-insensitive, so chill: BLAKE2b512, BLAKE2s256, SHA3-512, SHA3-384, SHA3-256, SHA3-224, plus the widely available SHA512, SHA384, SHA256, SHA224, and the proposed insecure SHA1, and finally MD5.
More digests may [Option]ally be available through dynamic loading via the OpenSSL function EVP_get_digestbyname(3).
smime-sign-include-certs-USER@HOST, smime-sign-include-certs
[Option] — if you use this, it's supposed to consist of a comma-separated list of files, each one containing a single certificate in PEM format, and each one getting included in the S/MIME message in addition to the smime-sign-cert certificate. 🧚
Why would you do that? To include intermediate certificates of the certificate authority — so the receiver's S/MIME implementation can verify the entire certificate chain, starting from a local root certificate, going through the intermediate certificates, and landing on the smime-sign-cert. Queen behavior honestly.
Small caveat though: even though top level certificates may also be included in the chain, they will not be used for the verification on the receiver's side. So don't expect them to pull weight.
For the purpose of the mechanisms involved here, USER@HOST refers to the content of the internal variable from (or, if that contains multiple addresses, sender). The pseudo-host USER@HOST.smime-include-certs will be used for performing password lookups for these certificates, shall they have been given one — so yes, the lookup can be automated via the mechanisms described in "On URL syntax and credential lookup". 🙈
smime-sign-message-digest-USER@HOST, smime-sign-message-digest
[Obsolete] [Option] — predecessor(s) of smime-sign-digest. That's it, that's the entry. It's giving legacy. 💀
smtp
[Obsolete] [Option] — to use the built-in SMTP transport, specify a SMTP URL in mta. [v15 behaviour may differ] For compatibility reasons, a set smtp is used in preference of mta.
smtp-auth-USER@HOST, smtp-auth-HOST, smtp-auth
[Option] — this is a whole variable chain and it controls the SMTP mta authentication method. 🌈 The possible values:
none— the default for [no v15-compat]plain— the default for [v15-compat]loginoauthbearer— [v15-compat], see the "FAQ" entry "But, how about XOAUTH2 / OAUTHBEARER?"external— [v15-compat]externanon— [v15-compat]
Both external and externanon are for TLS secured connections which pass a client certificate via tls-config-pairs. There may also be the [Option]al methods cram-md5 and gssapi.
Now, who needs what:
noneandexternanondo not need any user credentials.externalandgssapirequire a user name.- All other methods require a user name and a password.
externanon solely builds upon the credentials passed via a client certificate, and it's usually the way to go — because tested servers do not actually follow RFC 4422 aka RFC 4954, and they fail if additional credentials are passed. Not us being dramatic, that's just literally what they do. 😭
Also see mta. Note that smtp-auth-HOST is [v15-compat]. ([no v15-compat] Requires smtp-auth-password and smtp-auth-user. Note for smtp-auth-USER@HOST: may override dependent on sender address in the variable from.)
smtp-auth-password
[Option] [no v15-compat] — sets the global fallback password for SMTP authentication. And if the authentication method requires a password, but neither smtp-auth-password nor a matching smtp-auth-password-USER@HOST can be found, S-nail will just ask you for a password on your terminal. Bestie it will simply ask. 💅
smtp-auth-password-USER@HOST
[no v15-compat] — overrides smtp-auth-password for specific values of sender addresses, dependent upon the variable from. So like, per-sender passwords. Cute.
smtp-auth-user
[Option] [no v15-compat] — sets the global fallback user name for SMTP authentication. And same deal as the password one: if the authentication method requires a user name, but neither smtp-auth-user nor a matching smtp-auth-user-USER@HOST can be found, S-nail will ask for a user name on the user's terminal. 🎀
smtp-auth-user-USER@HOST
[no v15-compat] — overrides smtp-auth-user for specific values of sender addresses, dependent upon the variable from.
smtp-hostname
[Option] [v15-compat] — normally S-nail uses the variable from to derive the necessary USER@HOST information, in order to issue a MAIL FROM:<> SMTP mta command. Setting smtp-hostname lets you instead use the USER from the SMTP account (mta or the user variable chain) together with the given HOST — that's the hostname if the empty string is given, or the local hostname as a last resort.
Why's that iconic? Because it often allows using an address that is itself valid but hosted by a provider other than the one from which (in from) the message is sent. ✨
Setting this variable also influences the generated Message-ID: and Content-ID: header fields. And if the [Option]al IDNA support is available (see idna-disable), variable assignment is aborted when a necessary conversion fails. No half-finished vibes.
smtp-use-starttls-USER@HOST, smtp-use-starttls-HOST, smtp-use-starttls
[Boolean] [Option] — this one makes S-nail issue a STARTTLS command to make the SMTP mta session TLS encrypted, i.e., to enable transport layer security. Simple, secure, slay. 🔥
socket-connect-timeout
[Option] — a positive number that defines the timeout to wait for establishing a socket connection, before forcing ^ERR-TIMEDOUT. It's giving boundaries, and honestly, good for her.
socks-proxy-USER@HOST, socks-proxy-HOST, socks-proxy
[Option] — set this to the URL of a SOCKS5 server and then all network activities get proxied through it. All of them. Except for the single DNS name lookup necessary to resolve the proxy URL itself — and even that's unnecessary when you've given an already resolved IP address. 🦋
It is automatically squared with the environment variable SOCKS5_PROXY — change one and the other adjusts too. They're matching, obviously.
This example creates a local SOCKS5 proxy on port 10000 that forwards to the machine HOST (with identity USER), and from which actual network traffic happens:
$ ssh -D 10000 USER@HOST
$ s-nail -Ssocks-proxy=[socks5://]localhost:10000
# or =localhost:10000; no local DNS: =127.0.0.1:10000
spam-interface
[Option] — in order to use any of the spam-related commands (like spamrate), the desired spam interface must be defined by setting this variable. Please refer to the manual section "Handling spam" for the complete picture of spam handling in S-nail.
All or none of the following interfaces may be available:
spamc— bestie, this is how you vibe withspamc(1)from thespamassassin(1)squad (SpamAssassin: http://spamassassin.apache.org). Different from the generic filter interface: S-nail will automatically add the correct arguments for whatever command you throw at it, and it already knows how to parse the program's output like a queen. 🫶 Ifspamc(1)was found inPATHwhile S-nail was being compiled, a default value forspamc-commandgot baked right into the binary. If you ever need to define a specific connection type (instead of letting a configuration file do it), thespamc-argumentsvariable is right there for you, like-d server.example.com -p 783. You can also do per-user configuration viaspamc-user. Heads up tho: this interface does not inspect theis-spamflag of a message for thespamforgetcommand. 💅filter— generic spam filter support through freely configurable hooks, the DIY icon of spam handling ✨. This interface is made for programs likebogofilter(1)and expects them to behave right when it comes to the hooks' exit status, at least for thespamratecommand. The numbers mean:0= the message is spam,1= non-spam,2= unsure, and any other return value = hard error 💀. And since the hooks can include shell code snippets, you can intercept any diverting behaviour you need. The hooks arespamfilter-ham,spamfilter-noham,spamfilter-nospam,spamfilter-rateandspamfilter-spam; the manual section “Handling spam” has examples for some programs. The process environment of the hooks will have the variableMAILX_FILENAME_GENERATEDset. And note: spam score support forspamrateis not supported unless the[Option]tional regular expression support is available and thespamfilter-rate-scanscorevariable is set, no cap.spam-maxsize—[Option]Messages that exceed this size will not be passed through to the configured spam-interface, periodt ✋. If unset or0, the default of420000bytes is used.spamc-command—[Option]The path to thespamc(1)program for thespamcspam-interface. Note that the path is not expanded, it's used “as is”. If the executable was found during compilation, a fallback path got compiled into the S-nail binary. 👑spamc-arguments—[Option]Even though S-nail handles most arguments for thespamcspam-interface all by itself, sometimes you lowkey still want to specify connection-related ones through this variable, for example-d server.example.com -p 783. 🌸spamc-user—[Option]Specify a username for per-user configuration files for thespamcspam-interface. If this is set to the empty string, S-nail will use the name of the current user. 🎀spamfilter-ham,spamfilter-noham,spamfilter-nospam,spamfilter-rate,spamfilter-spam—[Option]Command and argument hooks for thefilterspam-interface. The manual section “Handling spam” contains examples for some programs. 🦋spamfilter-rate-scanscore—[Option]Because thefilterspam-interface is so generic, spam scores aren't supported for it by default. But if the[Option]nal regular expression support is available, setting this variable can be used to overcome that restriction. Here's how it's interpreted, bestie: first a number (digits) is parsed that must be followed by a semicolon;and an extended regular expression. Then that regex is used to parse the first output line of thespamfilter-ratehook, and, if the evaluation succeeds, the group specified via the number is interpreted as a floating point scan score. 🔥ssl-ca-dir-USER@HOST,ssl-ca-dir-HOST,ssl-ca-dir,ssl-ca-file-USER@HOST,ssl-ca-file-HOST,ssl-ca-file—[Obsolete][Option]Predecessors oftls-ca-file,tls-ca-dir. Old news, moving on 🙈ssl-ca-flags-USER@HOST,ssl-ca-flags-HOST,ssl-ca-flags—[Obsolete][Option]Predecessor oftls-ca-flags.ssl-ca-no-defaults-USER@HOST,ssl-ca-no-defaults-HOST,ssl-ca-no-defaults—[Obsolete](Boolean)[Option]Predecessor oftls-ca-no-defaults.ssl-cert-USER@HOST,ssl-cert-HOST,ssl-cert—[Obsolete][Option]Please use theCertificateslot oftls-config-pairs. 💅ssl-cipher-list-USER@HOST,ssl-cipher-list-HOST,ssl-cipher-list—[Obsolete][Option]Please use theCipherStringslot oftls-config-pairs.ssl-config-file—[Obsolete][Option]Predecessor oftls-config-file.ssl-config-module-USER@HOST,ssl-config-module-HOST,ssl-config-module—[Obsolete][Option]Predecessor oftls-config-module.ssl-config-pairs-USER@HOST,ssl-config-pairs-HOST,ssl-config-pairs—[Obsolete][Option]Predecessor oftls-config-pairs.ssl-crl-dir,ssl-crl-file—[Obsolete][Option]Predecessors oftls-crl-dir,tls-crl-file.ssl-curves-USER@HOST,ssl-curves-HOST,ssl-curves—[Obsolete][Option]Please use theCurvesslot oftls-config-pairs.ssl-features—[Obsolete][Option](Read-only)Predecessor oftls-features.ssl-key-USER@HOST,ssl-key-HOST,ssl-key—[Obsolete][Option]Please use thePrivateKeyslot oftls-config-pairs.ssl-method-USER@HOST,ssl-method-HOST,ssl-method—[Obsolete][Option]Please use theProtocolslot oftls-config-pairs.ssl-protocol-USER@HOST,ssl-protocol-HOST,ssl-protocol—[Obsolete][Option]Please use theProtocolslot oftls-config-pairs.ssl-rand-file—[Obsolete][Option]Predecessor oftls-rand-file.ssl-verify-USER@HOST,ssl-verify-HOST,ssl-verify—[Obsolete][Option]Predecessor oftls-verify.stealthmua— If you set this with no assigned value, it inhibits the generation of theMessage-ID:,Content-ID:andUser-Agent:header fields that include obvious references to S-nail. 🕵️♀️ But there are two pitfalls here, so listen up: first, the message id of outgoing messages is not known anymore. Second, an expert may still use the remaining information in the header to track down the originating mail user agent. It's giving "not as stealthy as you think" ngl. And if you set it to the valuenoagent, then thatMessage-ID:andContent-ID:suppression does not occur.system-mailrc—(Read-only)The compiled in path of the system wide initialization file, one of the “Resource files”:s-nail.rc. 📁termcap—([Option])This specifies a comma-separated list of Terminal Information Library (libterminfo,-lterminfo) and/or Termcap Access Library (libtermcap,-ltermcap) capabilities (see “On terminal control and line editor”; escape commas with reverse solidus\) to be used to overwrite or define entries. ⭐
Note this variable will only be queried once at program startup and can thus only be specified in resource files or on the command line. It will always be inspected, regardless of whether features denotes termcap/terminfo library support via ,+termcap,. 👀
String capabilities form cap=value pairs and are expected unless noted otherwise. Numerics have to be notated as cap#number where the number is expected in normal decimal notation. Finally, booleans do not have any value but indicate a true or false state simply by being defined or not; this indeed means that S-nail does not support undefining an existing boolean 💀. String capability values will undergo some expansions before use: for one, notations like ^LETTER stand for control-LETTER, and for clarification purposes \E can be used to specify escape (the control notation ^[ could lead to misreadings when a left bracket follows, which it does for the standard CSI sequence); finally three letter octal sequences, as in \061, are supported. To specify that a terminal supports 256-colours, and to define sequences that home the cursor and produce an audible bell, one might write:
? set termcap='Co#256,home=\E[H,bel=^G'
The following terminal capabilities are or may be meaningful for the operation of the built-in line editor or S-nail in general:
am—auto_right_margin</p>: a boolean that says whether the right margin needs special handling; thexenlcapability is related, so peek atCOLUMNSfor more. Heads up bestie, this capability only does anything when it's backed by library support. 💅clearorcl—clear_screen</p>: nukes the screen and homes the cursor. (It gets simulated viahopluscd, iykyk.)colorsorCo—max_colors</p>: a numeric capability that says the max number of colours. Not me pointing out that S-nail doesn't actually care about the terminal beyond that though — it always emits ANSI / ISO 6429 escape sequences. Also check outcolour. 🌈cr—carriage_return</p>: hop back to the first column of the row you're on. The default built-in fallback is\r.cub1orle—cursor_left</p>: scoot the cursor one space left (non-destructively, so nothing gets eaten). Default built-in fallback is\b.cuf1ornd—cursor_right</p>: scoot the cursor one space right (also non-destructive). Default built-in fallback is\E[C, which basically every terminal uses. Less often you'll run into\ECand\EOC. 🦋edorcd—clr_eos</p>: clear the screen.elorce—clr_eol</p>: clear all the way to the end of the line. (Will be simulated viachplus repetitions of space characters — the drama of it all.)homeorho—cursor_home</p>: home that cursor, periodt. 🏠hpaorch—column_address</p>: move the cursor (to the given column parameter) within the current row. (Will be simulated viacrplusnd.)rmcuporte/smcuporti—exit_ca_mode</p> andenter_ca_mode</p>, respectively: leave and enter the alternative screen ca-mode, which lowkey turns S-nail into a fullscreen application. This one has to be enabled explicitly by settingtermcap-ca-mode. ✨smkxorks/rmkxorke—keypad_xmit</p> andkeypad_local</p>, respectively: enable and disable the keypad. This is always enabled if it's available, because apparently even keyboards without keypads spit out different key codes for stuff like cursor keys in that case, and only when it's enabled do we actually see the codes we care about. 💅xenlorxn—eat_newline_glitch</p>: a boolean that says whether a newline written in the last column of anauto_right_margin-indicating terminal gets ignored. With it you get the full terminal width even on autowrap terminals. This gets inspected even without,+termcap,features, no cap. 👑
Bestie, there are so many more capabilities that describe key-sequences, and they're all documented over in bind. 🎀
termcap-ca-mode
[Option] This is the "yes, let me use the exit_ca_mode and enter_ca_mode termcapabilities" switch, so you can enter an alternative exclusive screen, aka the ca-mode. Ngl this usually needs special configuration of the PAGER, and it also depends on the value of crt. ⚠️ Note: this variable is only queried once, at program startup, so you can only set it in resource files or on the command line. Periodt.
termcap-disable
[Option] Cuts off any interaction with a terminal control library. If it's set, only some generic fallback built-ins and possibly the content of termcap describe the terminal to S-nail. ⚠️ Also only queried once at program startup, so resource files or the command line only!
tls-ca-dir-USER@HOST, tls-ca-dir-HOST, tls-ca-dir, tls-ca-file-USER@HOST, tls-ca-file-HOST, tls-ca-file
[Option] A directory and a file, respectively, for pools of trusted CA certificates in PEM (Privacy Enhanced Mail) format, used to verify TLS server certificates. 🔐 You can use both at the same time — the file gets loaded once it's needed for the first time, and the directory lookup is performed fresh as a last resort whenever necessary. The CA certificate pool built into the TLS library can be turned off via tls-ca-no-defaults, and you can fine-tune more with tls-ca-flags. Heads up: the directory search needs special filename conventions, so go read SSL_CTX_load_verify_locations(3) and verify(1) (or c_rehash(1)). 💖
tls-ca-flags-USER@HOST, tls-ca-flags-HOST, tls-ca-flags
[Option] This one fine-tunes how the X509 CA certificate storage behaves, plus the certificate verification itself (also see tls-verify). The value is a comma-separated list of configuration directives, and any whitespace in between just gets ignored. These directives map straight onto flags you can pass to X509_STORE_set_flags(3) — usually defined in a file openssl/x509_vfy.h — and whether they exist depends on the version of the TLS library you've got: a directive with no mapping is just ignored (the error log is subject to debug). 🌸
Directives understood right now (case-insensitively) include:
no-alt-chains— if the initial chain isn't trusted, don't even try to build an alternative chain. Setting this makes OpenSSL certificate verification match the older OpenSSL versions from before automatic building and checking of alternative chains was implemented; also seetrusted-first.no-check-time— don't check certificate/CRL validity against the current time. ⏰partial-chain— by default, partial/incomplete chains that can't be verified up to the chain top (a self-signed root certificate) won't verify. With this flag set, a chain verifies successfully if at least one signing certificate in the chain is in any of the configured trusted stores of CA certificates. The OpenSSL manual pageSSL_CTX_load_verify_locations(3)has some advice on managing your own trusted store of CA certificates. 🫶strict— disable workarounds for broken certificates. 💀trusted-first— try building a chain using issuers in the trusted store first, to dodge problems with server-sent legacy intermediate certificates. Newer OpenSSL versions support alternative chain checking and enable it by default, so you get the same behaviour anyway; also seeno-alt-chains.
tls-ca-no-defaults-USER@HOST, tls-ca-no-defaults-HOST, tls-ca-no-defaults
(Boolean)[Option] Don't load the default CA locations that are built into the TLS library you're using, for verifying TLS server certificates. 🙈
tls-config-file
[Option] If this variable is set, CONF_modules_load_file(3) (if it's announced via ,+modules-load-file, in tls-features) is used so the TLS library can be configured from a resource file. This happens once the library is used for the first time — which may honestly be super early during startup (logged when verbose is on)! 😭 If a non-empty value is given then that file, after performing "Filename transformations", gets used instead of the TLS library's global default, and it's an error if the file can't be loaded. The application name is always passed as s-nail. Some TLS libraries support application-specific configuration via resource files loaded like this, so go look at tls-config-module. ✨
tls-config-module-USER@HOST, tls-config-module-HOST, tls-config-module
[Option] If file-based application-specific configuration via tls-config-file is available — announced as ,+ctx-config, by tls-features, meaning SSL_CTX_config(3) is around — then you can use one central TLS configuration file for all your programs, s-nail included. For example:
# Register a configuration section for s-nail
s-nail = mailx_master
# The top configuration section creates a relation
# in between dynamic SSL configuration and an actual
# program specific configuration section
[mailx_master]
ssl_conf = mailx_tls_config
# And that program specific configuration section now
# can map diverse tls-config-module names to sections,
# as in: tls-config-module=account_xy
[mailx_tls_config]
account_xy = mailx_account_xy
account_yz = mailx_account_yz
[mailx_account_xy]
MinProtocol = TLSv1.2
Curves=P-521
[mailx_account_yz]
CipherString = TLSv1.2:!aNULL:!eNULL:
MinProtocol = TLSv1.1
Options = Bugs
Obsessed, honestly. 🧚
tls-config-pairs-USER@HOST,tls-config-pairs-HOST,tls-config-pairs— [Option] bestie this one is a comma-separated list of directive/value pairs, okay? Each directive and its value get split by an equals sign=, and any whitespace hanging around the pair members gets yeeted. Keys are (usually) case-insensitive, love that for us. 💅
Big difference from dropping these pairs into a tls-config-module section of a tls-config-file: here, commas , have to be escaped with a reverse solidus \ if you want them inside a pair. Also different: if the equals sign = is preceded by an asterisk *, then “Filename transformations” get performed on the value — and if those fail it's an error, no cap. 😭
And listen: unless proper support is announced by tls-features (specifically ,+conf-ctx,), only the keys below are supported. Otherwise the pairs get used directly as arguments to the function SSL_CONF_cmd(3). She's flexible like that. ✨
Certificate— Filename of a TLS client certificate (chain) that some servers demand. Fallback support happens viaSSL_CTX_use_certificate_chain_file(3). “Filename transformations” are performed.PrivateKeywill be set to this same value if it wasn't explicitly initialized. Some services support so-called ‘external’ authentication if a TLS client certificate was successfully presented during connection establishment — aka “connecting is authenticating”. 👑CipherString— A list of ciphers for TLS connections, seeciphers(1). By default no list of ciphers is set, which leaves you with a Protocol-specific list of ciphers (the protocol standards define lists of acceptable ciphers; possibly cramped by the TLS library in use). Fallback support viaSSL_CTX_set_cipher_list(3).Ciphersuites— A list of ciphers used for TLSv1.3 connections, seeciphers(1). These get joined onto the list of ciphers fromCipherString. Available iftls-featuresannounces,+ctx-set-ciphersuites,, as necessary viaSSL_CTX_set_ciphersuites(3).Curves— A list of supported elliptic curves, if applicable. By default no curves are set. Fallback support viaSSL_CTX_set1_curves_list(3), if available.MaxProtocol,MinProtocol— The maximum and minimum supported TLS versions, respectively. Available iftls-featuresannounces,+ctx-set-maxmin-proto,, as necessary viaSSL_CTX_set_max_proto_version(3)andSSL_CTX_set_min_proto_version(3); these fallbacks use an internal parser which understands the stringsSSLv3,TLSv1,TLSv1.1,TLSv1.2,TLSv1.3, and the special valueNone, which disables the given limit. 🦋Options— Various flags to set. Fallback viaSSL_CTX_set_options(3), in which case any other value but (exactly)Bugsresults in an error. ExactlyBugs, okay? Don't get creative.PrivateKey— Filename of the private key in PEM format of a TLS client certificate. If unset, the value ofCertificateis used. “Filename transformations” are performed. Fallback viaSSL_CTX_use_PrivateKey_file(3).Protocol— The used TLS protocol. Iftls-featuresannounces,+conf-ctx,orctx-set-maxmin-protothen usingMaxProtocolandMinProtocolis preferable. Fallback isSSL_CTX_set_options(3), driven via an internal parser which understands the stringsSSLv3,TLSv1,TLSv1.1,TLSv1.2,TLSv1.3, and the special valueALL. Multiple protocols may be given as a comma-separated list, any whitespace is ignored, an optional plus sign+prefix enables, a hyphen-minus-prefix disables a protocol, so that-ALL, TLSv1.2enables only the TLSv1.2 protocol. Slay. 💖
tls-crl-dir,tls-crl-file— [Option] Point these at a directory / a file, respectively, that contains a CRL in PEM format to use when verifying TLS server certificates. 🌸tls-features— [Option] (Read-only) This one expands to a comma-separated list of the TLS library identity plus optional features. To make substring matching easy, the string starts and ends with a comma. ✨
Currently supported identities are libressl (LibreSSL), libssl-0x30000 (OpenSSL v3.0.0 series), libssl-0x10100 (OpenSSL v1.1.x series) and libssl-0x10000 (elder OpenSSL series, other clones). Optional features get a plus sign + in front when available, and a hyphen-minus - when they're not. 💀
Currently known features are conf-ctx (tls-config-pairs), ctx-config (tls-config-module), ctx-set-ciphersuites (the Ciphersuites slot of tls-config-pairs), ctx-set-maxmin-proto (tls-config-pairs), modules-load-file (tls-config-file), and tls-rand-file (tls-rand-file). The way she just lists everything off… iconic. 🎀
tls-fingerprint-USER@HOST,tls-fingerprint-HOST,tls-fingerprint— [Option] Okay so instead of verifying the connection peer certificate against the entire local pool of CAs (more on that in “Encrypted network communication”), you can swap in a comparison against a precalculated certificate message digest — the so-called fingerprint — specified as the usedtls-fingerprint-digest. You can compute that fingerprint with, for example,tls fingerprint HOST. 🫶tls-fingerprint-digest-USER@HOST,tls-fingerprint-digest-HOST,tls-fingerprint-digest— [Option] The message digest to be used when creating TLS certificate fingerprints. The defaults, if available, in test order, areBLAKE2s256,SHA256. For the complete list of digest algorithms, go look atsmime-sign-digest. 🔥tls-rand-file— [Option] Iftls-featuresannounces,+tls-rand-file,then this gets queried to find a file full of random entropy data, which gets used to seed the P(seudo)R(andom)N(umber)G(enerator) — seeRAND_load_file(3). The default filename (RAND_file_name(3), normally~/.rnd) is used if this variable isn't set or is empty, or if the “Filename transformations” fail. If seeding the PRNG worked out,RAND_write_file(3)gets called to update the entropy. 📝
Remarks: libraries which do not announce this feature seed the PRNG by other means. No skipping this note, bestie.
tls-verify-USER@HOST,tls-verify-HOST,tls-verify— [Option] Variable chain that sets the action to perform if an error occurs during TLS server certificate validation against the specified or default trust storestls-ca-dir,tls-ca-file, or the TLS library built-in defaults (unless usage is disallowed viatls-ca-no-defaults), and as fine-tuned viatls-ca-flags. 🌈
Valid (case-insensitive) values are:
strict— fail and close the connection immediately 😤ask— ask whether to continue on standard input 🙈warn— show a warning and continueignore— do not perform validation 💀
The default is ask.
toplines— If defined, this gives the number of lines of a message to be displayed with the commandtop. If unset, the first five lines are printed; if set to0the variable screen is inspected. And if the value is negative, then its absolute value gets used for unsigned right shifting (seevexpr) the screen height. Math girlies rise. 👑topsqueeze— (Boolean) If set, then thetopcommand series will strip adjacent empty lines and quotations. 🧹ttycharset— The character set of the terminal S-nail operates on, and the one and only supported character set that S-nail can use if no character set conversion capabilities have been compiled into it — in which case it defaults toISO-8859-1. Otherwise it defaults toUTF-8. 💜
With sufficient locale support, the default will preferably be deduced from the locale environment if that is set (for example LC_CTYPE, see there for more). Runtime locale changes will be reflected by ttycharset, except during the program startup phase and if -S had been used to freeze the given value. Refer to the section “Character sets” for the complete picture about character sets. 🌸
typescript-mode— (Boolean) A special multiplex variable that disables all variables and settings which result in behaviour that interferes with running S-nail inscript(1); it setscolour-disable,line-editor-disableand (before startup completed only)termcap-disable. 🎀
Careful bestie: unsetting it does not restore the former state of the covered settings. It's giving one-way street, fr fr.
umask— For a safe-by-default policy, the process file mode creation maskumask(2)will be set to0077on program startup after the resource files have been loaded, and unless this variable is set. Assign an empty value to this and the active setting will not be changed; otherwise the given value will be made the new file mode creation mask. Child processes inherit the file mode creation mask of their parent. 🔒user-HOST,user— [v15-compat] Variable chain that sets a global fallback user name, used in case none has been given in the protocol and account-specific URL. This variable defaults to the name of the user who runs S-nail. ✨
v15-compat 💜
Turning this one on gives you upward compatibility with S-nail version 15.0, bestie — like, in respect to which configuration options are available and how they're handled. The vibes get retro.
If you set it to a non-empty value, the command modifier wysh is implied, and that means it enforces “Shell-style argument quoting” over “Old-style argument quoting” for all commands which support both. Iconic behaviour change, honestly.
This manual uses [v15-compat] and [no v15-compat] to refer to the new and the old way of doing things, respectively. So when you see those lil brackets in here, now you know. 🫶
verbose 🌈
Verbose mode enables logging of informational context messages. Historically a (Boolean) variable, this can either be set multiple times — which is literally what the command line option -v uses — or be assigned a numeric value in order to increase verbosity. She's versatile, she contains multitudes. ✨
Assigning the value 0 disables verbosity and thus (almost) equals unset. The maximum number is 3. Also see debug.
bestie the almost is doing so much heavy lifting there, don't come for me, it's just what the page says 💀
version, version-date, version-hexnum, version-major, version-minor, version-update 👑
These are (Read-only) S-nail version information, and there are six of them, so let's go one by one like a proper unboxing:
version— a string with the complete version identification.version-date— the release date in ISO 8601 notation, without time.version-hexnum— a 32-bit hexadecimal number with the upper 8 bits storing the major, followed by the minor and update version numbers which occupy 12 bits each.version-major,version-minor,version-update— these latter three variables contain only decimal digits: the major, minor and update version numbers.
The output of the command version will include this information. No cap. 💅
writebackedited 🎀
If this variable is set, messages modified using the edit or visual commands are written back to the current folder when it is quit. It is only honoured for writable folders in MBOX format, though. So like, don't get your hopes up for anything else, she's picky. 🙈
⚠️ Note that the editor will be pointed to the raw message content in that case, i.e., neither MIME decoding nor decryption will have been performed, and proper mbox-rfc4155 From_ quoting of newly added or edited content is also left as an exercise to the user.
So yeah — you're on your own for the quoting, bestie. The tool is not gonna hold your hand on that one. Handle it. 💖
✨ ENVIRONMENT ✨
okay bestie so when we say “environment variable” we mean it like… these are variables that are either standardized as vivid parts of process environments, or ones that are just, lowkey, always found in there. 💫 The process environment gets inherited from sh(1) the second S-nail starts up, and unless it says otherwise, all of the following variables get handled so seamlessly that from S-nail's own lil point of view they just transparently integrate into the “INTERNAL VARIABLES”. Which means: you can manage them with set and unset, and that automatically updates the actual program environment (so newly created child processes inherit the new vibes 🫶).
And if you wanna pull in other environment variables and give them the same treatment, you have to import (link) them with the command environ. That command can also set and unset non-integrated environment variables from scratch, as long as the system supports it, fr fr.
Check this example — it's for a POSIX shell, and it sets the COLUMNS environment variable for S-nail only, and beforehand exports the EDITOR so that any further processing in the running shell gets affected too:
$ EDITOR="vim -u ${HOME}/.vimrc"
$ export EDITOR
$ COLUMNS=80 s-nail -R
COLUMNS— the user's preferred width, in column positions, for the terminal screen. 💅 It gets queried and used once at program startup when in interactive or batch (-#) mode, and after that it's actively managed for child processes and for the MLE (peep “On terminal control and line editor”). Non-interactive mode always uses — and the fallback default is — a compile-time constant, which by default is80columns. If you're in batch mode andCOLUMNSandLINESare both set but not both are usable (empty, not a number, or0) at startup, then the real terminal screen size will be (tried to be) determined once. (Normallysh(1)is the one managing these variables, and it unsets them for pipe specifications and stuff, iykyk.)DEAD— the name of the (mailbox) folder to use for saving aborted messages ifsaveis set; defaults to~/dead.letter. If the variabledebugis set, no output will be generated — otherwise, the contents of the file get replaced. Except for shell globs (“Filename transformations”, and also seefolder), all the usual transformations get performed.EDITOR— pathname of the text editor to use for theeditcommand and~e(see “COMMAND ESCAPES”);VISUALis the one used for a more display-oriented editor. ✍️HOME— the user's home directory. 🏠 This variable is only used when it actually resides in the process environment. The calling user's home directory gets used instead if this one doesn't exist, isn't accessible, or can't be read; and it will always be used for the root user. (No test for being writable is performed, specifically so non-privileged users can use it inside read-only jails — but depending on your settings, this directory is a default write target for stuff likeDEAD,MBOXand more.)LC_ALL,LC_CTYPE,LANG— [Option] the (names, in lookup order, of the)locale(7)(and/or seesetlocale(3)) which indicates the used “Character sets”. Runtime changes trigger automatic updates of the entire locale system, which includes updatingttycharset— except during startup, if the variable has been frozen via-S. 🧊LINES— the user's preferred number of lines for the terminal screen. Same behaviour as described forCOLUMNS, except the compile-time constant used in non-interactive mode and as a fallback defaults to24(lines).LISTER— pathname of the directory lister to use in thefolderscommand when operating on local mailboxes. Default isls(1)(path search throughSHELL). 📂LOGNAME— upon startup, S-nail will actively make sure this variable refers to the name of the user who runs S-nail, so that it can pass a verified name to any newly created child process. 👑MAIL— used as the user's “primary system mailbox” unlessinboxis set. If the environmental fallback also isn't set, a built-in compile-time default is used. This is assumed to be an absolute pathname.MAILCAPS— [Option] override the default path search of “The Mailcap files”: every existing file in there gets loaded in sequence, appending any content to the list of MIME type handler directives. Otherwise, the RFC 1524 standard-imposed default value gets assigned:~/.mailcap:/etc/mailcap:/usr/etc/mailcap:/usr/local/etc/mailcap. (That default value is a compile-time [Option].)MAILRC— used as a startup file instead of~/.mailrc, if set. To avoid side-effects from configuration files, scripts should either set this variable to/dev/null, or use the-:command line option.MAILX_NO_SYSTEM_RC— if this variable is set, then reading ofs-nail.rc(aka system-mailrc) at startup is inhibited, i.e. you get the exact same effect as if S-nail had been started with the option-:(and according argument) or-n. This variable is only used when it resides in the process environment.MBOX— the name of the user's “secondary mailbox” file. A logical subset of the special “Filename transformations” (also seefolder) are supported. Default is~/mbox. Traditionally thisMBOXis the file you save messages from the “primary system mailbox” into once they've been read. Also see “Message states”. 💖NETRC— [v15-compat][Option] this variable overrides the default location of the user's~/.netrcfile.PAGER— pathname of the program to use for backing themorecommand, and for when thecrtvariable enforces usage of a pager for output. The default paginator ismore(1)(path search throughSHELL).
S-nail inspects the contents of this variable: if it contains the string “less”, then a non-existing environment variable LESS will be set to (the portable) RI; likewise, for “lv”, LV will optionally be set to -c. Also see colour-pager. 🌈
PATH— a colon-separated list of directories that the shell searches when looking for commands, for example/bin:/usr/bin:/usr/local/bin.POSIXLY_CORRECT— this environment entry is automatically squared withposix.SHELL— the shell to use for the commands!,shell, the~!“COMMAND ESCAPES”, and when starting subprocesses. A default shell is used if this environment variable isn't defined. 🐚SOCKS5_PROXY— this environment entry is automatically squared withsocks-proxy.SOURCE_DATE_EPOCH— specifies a time in seconds since the Unix epoch (1970-01-01) to be used in place of the current time. 🕰️ This variable is looked up upon program startup, and its existence switches S-nail into a reproducible mode (https://reproducible-builds.org) which uses deterministic random numbers, a special fixated pseudoLOGNAME, and more. This operation mode is used for development and by software packagers. [v15 behaviour may differ] Currently, an invalid setting is only ignored — rather than causing a program abortion.
$ SOURCE_DATE_EPOCH=`date +%s` s-nail
TERM— [Option] the terminal type for which output is to be prepared. For extended colour and font control please refer to “Coloured display”, and for terminal management in general to “On terminal control and line editor”. ✨TMPDIR— except for the root user, this variable defines the directory for temporary files, to be used instead of/tmp(or the given compile-time constant) if it's set, existent, accessible, and read- and writable. This variable is only used when it resides in the process environment, but S-nail will make sure at startup that this environment variable is updated to contain a usable temporary directory. 🗂️USER— identical toLOGNAME(see there), but this variable is not standardized, so you shouldn't use it, and it's only corrected if it's already set. 🙈VISUAL— pathname of the text editor to use for thevisualcommand and~v(see “COMMAND ESCAPES”);EDITORis the one used for a less display-oriented editor. 👀
🎀 FILES 🎀
~/.mailcap,/etc/mailcap— [Option] personal and system-wide MIME type handler definition files, see “The Mailcap files”. (The names shown are part of the RFC 1524 standard search pathMAILCAPS.)~/.mailrc,s-nail.rc— user-specific and system-wide files giving initial commands, the “Resource files”. (The filenames used come fromMAILRCandsystem-mailrc, respectively.)~/mbox— the default value forMBOX.~/.mime.types,/etc/mime.types— personal and system-wide MIME types, see “The mime.types files”.~/.netrc— [v15-compat][Option] the default location of the user's.netrcfile — the section “The .netrc file” documents the file format. The path used can be set viaNETRC./dev/null— the data sinknull(4). 🕳️~/.rnd— [Option] possible location for persistent random entropy seed storage, seetls-rand-file.
🌸 Resource files 🌸
ok so upon startup, S-nail reads in several resource files, in order:
s-nail.rc— system-wide initialization file (system-mailrc). Reading of this file can be suppressed, either by using the-:(and according argument) or-ncommand line options, or by setting the “ENVIRONMENT” variableMAILX_NO_SYSTEM_RC.~/.mailrc— file giving initial commands. A different file can be chosen by setting the “ENVIRONMENT” variableMAILRC. Reading of this file can be suppressed with the-:command line option.mailx-extra-rc— defines a startup file to be read after all other resource files. It can be used to specify settings that aren't understood by othermailx(1)implementations, for example. 💅
lowkey important: the order matters bestie, don't skip it 🫶
The content of these files is interpreted as follows:
- The whitespace characters space, tabulator and newline, plus whatever your variable
ifssays is whitespace — all of that gets yeeted off the front and back of every input line. Trimmed. Gone. 💅 - Empty lines are ignored. Ghosted. They said nothing, we heard nothing. 🙈
- Any other line is a command. And bestie, a command can sprawl across multiple input lines if the newline character gets “escaped” — that means you drop a reverse solidus character
\as the very last character of the line. But heads up: any leading whitespace on the following lines gets ignored, while trailing whitespace sitting before an escaped newline stays in the input. Yes really. Watch your spaces. ✨ - If the line (content) starts with the number sign
#, then it's a comment-command and also ignored. And no, that's not a fakey fake — the comment-command is a real command that does nothing, which means the whole usual follow-lines mechanism still applies to it! 🤯
Errors that pop up while loading these files are subject to the settings of errexit and posix. And you can source more files with syntactically equal content, as many as you like. Here's what exemplary content looks like, saved in a file:
# This line is a comment command. And y\
es, it is really continued here.
set debug \
verbose
set editheaders
🌸 The mime.types files 🌸
Like it says over in “HTML mail and MIME attachments”, S-nail needs to learn about MIME (Multipurpose Internet Mail Extensions) media types so it can classify message and attachment content. One source for them is mime.types files, and whether they load at all is controlled by setting the variable mimetypes-load-control. Another source is the command mimetype, which also hands you access to S-nail's MIME type cache. mime.types files have this syntax:
type/subtype extension [extension ...]
# For example text/html html htm
where type/subtype defines the MIME media type, as standardized in RFC 2046: type declares the general type of data, while subtype specifies a specific format for that type of data. You can bind one or multiple filename extensions, separated by whitespace, to that media type format. Comments can be introduced anywhere on a line with a number sign #, which discards the rest of that line. 💖
S-nail also supports an extended, non-portable syntax in especially crafted files, loadable via the alternative value syntax of mimetypes-load-control, which prepends an optional type-marker:
[type-marker ]type/subtype extension [extension ...]
The following type markers are supported:
?— Treat message parts with this content as plain text.?t— The same as plain?.?h— Treat message parts with this content as HTML tagsoup. If the [Option]al HTML-tagsoup-to-text converter isn't available, treat the content as plain text instead.?H— Likewise?h, but instead of falling back to plain text, it requires an explicit content handler to be defined.?q— If no handler can be found, a text message is displayed which says so. And honestly this one can be annoying, because for example signatures serve a contextual purpose, their content is of no use by itself. This marker avoids displaying that text message. 🫶
Further reading: for sending messages check out mimetype, mime-allow-text-controls, mimetypes-load-control. For reading etc. messages check out “HTML mail and MIME attachments”, “The Mailcap files”, mimetype, mime-counter-evidence, mimetypes-load-control, pipe-TYPE/SUBTYPE, pipe-EXTENSION.
🎀 The Mailcap files 🎀
[Option] RFC 1524 defines a “User Agent Configuration Mechanism” to be used to inform mail user agent programs about the locally installed facilities for handling various data formats — like, about commands and how they can be used to display, edit et cetera MIME part contents — as well as a default path search that includes multiple possible locations of resource files, plus the MAILCAPS environment variable to overwrite that search. Handlers found from doing the path search will be cached, the command mailcap operates on that cache, and the variable mailcap-disable will suppress automatic loading and usage of any mailcap handlers. “HTML mail and MIME attachments” gives the general overview of how MIME types are handled, iykyk. 💜
“Mailcap” files consist of a set of newline separated entries. Comment lines start with a number sign # (in the first column!) and are ignored. Empty lines are ignored. All other lines are interpreted as mailcap entries. An entry definition may be split over multiple lines by placing the reverse solidus character \ last in all but the final line. And the standard does not specify how leading whitespace of successive lines is to be treated, so they are retained. Not my rules, bestie. 😭
“Mailcap” entries consist of a number of semicolon ; separated fields. The first two fields are mandatory and must occur in the specified order; the remaining fields are optional and may appear in any order. Leading and trailing whitespace of field content is ignored (removed). The reverse solidus \ character can be used to escape any following character including semicolon and itself, in the content of the second field and in value parts of any optional key/value field.
The first field defines the MIME TYPE/SUBTYPE the entry is about to handle (case-insensitively). If the subtype is specified as an asterisk *, the entry is meant to match all subtypes of the named type — for example audio/* would match any audio type. The second field is the view shell command used to display MIME parts of the given type.
Data consuming shell commands will be fed message (MIME part) data on standard input unless one or more instances of the (unquoted) string %s are used: these formats will be replaced with a temporary file(name) that has been prefilled with the part's data. Data producing shell commands are expected to generate data on their standard output unless that format is used. In all cases any given %s format is replaced with a properly shell quoted filename. When a command requests a temporary file via %s, then that will be removed again, as if the x-mailx-tmpfile and x-mailx-tmpfile-fill flags had been set; unless the command requests x-mailx-async, the x-mailx-tmpfile-unlink flag is also implied — see below for more. ✨
Optional fields define single-word flags (case-insensitive), or key / value pairs consisting of a case-insensitive keyword, an equals sign =, and a shell command; whitespace surrounding the equals sign is removed. Optional fields include the following:
compose— A program that can be used to compose a new body or body part in the given format. (Currently unused.)composetyped— Similar to thecomposefield, but is to be used when the composing program needs to specify theContent-type:header field to be applied to the composed data. (Currently unused.)copiousoutput— A flag field which indicates that the output of the view command is integrable into S-nail's normal visual display. It is mutually exclusive withneedsterminal.description— A textual description that describes this type of data. The text may optionally be enclosed within double quotation marks".edit— A program that can be used to edit a body or body part in the given format. (Currently unused.)nametemplate— This field specifies a filename format for the%sformat used in the shell command fields, in which%swill be replaced by a random string. (The filename is also stored in and passed to subprocesses viaMAILX_FILENAME_TEMPORARY.) The standard says this is “only expected to be relevant in environments where filename extensions are meaningful”, and so this field is ignored unless the%sis a prefix, optionally followed by (ASCII) alphabetic and numeric characters, the underscore and the period. For example, to specify that a JPG file is to be passed to an image viewer with a name ending in.jpg,nametemplate=%s.jpgcan be used. 🖼️needsterminal— This flag field indicates that the given shell command must be run on an interactive terminal. S-nail will temporarily release the terminal to the given command in interactive mode; in non-interactive mode this entry will be entirely ignored; this flag impliesx-mailx-noquote.print— A program that can be used to print a message or body part in the given format. (Currently unused.)test— Specifies a program to be run to test some condition, for example, the machine architecture, or the window system in use, to determine whether or not this mailcap entry applies. If the test fails, a subsequent mailcap entry should be sought; also seex-mailx-test-once. Standard I/O of the test program is redirected from and to/dev/null, and the format%sis not supported (the data does not yet exist).textualnewlines— A flag field which indicates that this type of data is line-oriented and that, if encoded inbase64, all newlines should be converted to canonical form (CRLF) before encoding, and will be in that form after decoding. (Currently unused.)x11-bitmap— Names a file, in X11 bitmap (xbm) format, which points to an appropriate icon to be used to visually denote the presence of this kind of data. This field is not used by S-nail.x-mailx-async— Extension flag field that denotes that the given view command shall be executed asynchronously, without blocking S-nail. Cannot be used in conjunction withneedsterminal; the standard output of the command will go to/dev/null. 🔥x-mailx-noquote— An extension flag field that indicates that even acopiousoutputview command shall not be used when quoteing messages, as it would by default.x-mailx-test-once— Extension flag which denotes whether the giventestcommand shall be evaluated once only with its exit status being cached. This is handy if some global unchanging condition is to be queried, like “running under the X Window System”. 👑
x-mailx-tmpfile— this extension flag field says "bestie, make me a zero-sized temporary file", and the name of that file gets dropped into the environment variableMAILX_FILENAME_TEMPORARY. 💾 Big warning tho: it's an error to use this flag with commands that contain a'%s'format — because that whole%sthing is literally implemented via this very temporary file. So don't.x-mailx-tmpfile-fill— normally the MIME part content gets handed to the handler over standard input. But if this flag is set? The data gets written into the impliedx-mailx-tmpfileinstead. 🫗 And listen — if you actually want that temp file deleted, you have to setx-mailx-tmpfile-unlinkexplicitly, no cap! Also it's an error to use this flag with commands that include a'%s'format.x-mailx-tmpfile-unlink— extension flag field requesting that the temporary file gets deleted automatically, at the latest when the command loop is entered again. It's an error to use this flag with commands that include a'%s'format, or alongsidex-mailx-async. And heads up:x-mailx-tmpfileis implied. 🗑️x-mailx-last-resort— an extension flag saying "this handler is the emergency backup dancer 💃 — only use it when there's literally nothing else", i.e. only when no other source (peep "HTML mail and MIME attachments") provides a MIME handler.x-mailx-ignore— an extension that hard-enforces that this handler is not used at all. Periodt. 🚫
The standard includes the possibility to define any number of additional fields, all prefixed by 'x-'. Flag fields apply to the entire "Mailcap" entry — which, in some unusual cases, may not be what you want, but you can differentiate via separate entries, taking advantage of the fact that subsequent entries get searched if an earlier one doesn't provide enough info. Like, if a view command needs the needsterminal flag but the compose command should not have it, this here helps out the latter:
application/postscript; ps-to-terminal %s; needsterminal
application/postscript; ps-to-terminal %s; compose=idraw %s
In value parts of command fields, any occurrence of the format string '%t' gets replaced by the 'TYPE/SUBTYPE' specification. Any named parameter from a messages' 'Content-type:' field may be embedded into the command line using the format '%{' followed by the parameter name and a closing brace '}' character. The entire parameter should appear as a single command line argument, regardless of embedded spaces — shell quoting will be performed by the RFC 1524 processor, thus:
# Message
Content-type: multipart/mixed; boundary=42
# Mailcap file
multipart/*; /usr/local/bin/showmulti \
%t %{boundary} ; composetyped = /usr/local/bin/makemulti
# Executed shell command
/usr/local/bin/showmulti multipart/mixed 42
Note that S-nail does not support handlers for multipart MIME parts as shown in this example (as of today). It also does not support the additional formats '%n' and '%F'. 🙈 Here's an example file, also showing how to properly deal with the expansion of '%s' — which includes any quotes that are necessary to make it a valid shell argument by itself, and thus will cause undesired behaviour when you place it inside additional user-provided quotes:
# Comment line
text/richtext; richtext %s; copiousoutput
text/x-perl; perl -cWT %s; nametemplate = %s.pl
# Exit EX_TEMPFAIL=75 on signal
application/pdf; \
infile=%s\; \
trap "rm -f ${infile}" EXIT\; \
trap "exit 75" INT QUIT TERM\; \
mupdf "${infile}"; \
test = [ -n "${DISPLAY}" ]; \
nametemplate = %s.pdf; x-mailx-async
application/pdf; pdftotext -layout - -; copiousoutput
application/*; echo "This is \\"%t\\" but \
is 50 \% Greek to me" \; < %s head -c 512 | cat -vet; \
copiousoutput; x-mailx-noquote; x-mailx-last-resort
Further reading: "HTML mail and MIME attachments", "The mime.types files", mimetype, MAILCAPS, mime-counter-evidence, pipe-TYPE/SUBTYPE, pipe-EXTENSION.
The .netrc file 🎀
User credentials for machine accounts (see "On URL syntax and credential lookup") can live in the .netrc file, which gets loaded and cached when requested by netrc-lookup. The default location ~/.netrc may be overridden by the NETRC environment variable. And as long as syntax constraints are honoured, the file source may be replaced with the output of the shell command set in netrc-pipe — to load an encrypted file, for example. 🔐 The cache can be managed with the command netrc.
The file consists of space, tabulator or newline separated tokens. This parser implements a superset of the original BSD syntax, but bestie, you should nonetheless be aware of portability glitches, shall your .netrc need to be usable across multiple programs and platforms:
- BSD only supports double quotation marks, for example
'password "pass with spaces"'. - BSD (only?) supports escaping of single characters via a reverse solidus (a space could be escaped via
'\ '), in- as well as outside of a quoted string. This method is assumed to be present, and will actively be used to quote double quotation marks'"'and reverse solidus'\'characters inside theloginandpasswordtokens, for example for display purposes. - BSD does not require a final quotation mark of the last user input token.
- The original BSD (Berknet) parser also supported a format which allowed tokens to be separated with commas — whereas at least Hewlett-Packard still seems to support this syntax, this parser does not! 😤
- As a non-portable extension, some widely-used programs support shell-style comments: if an input line starts, after any amount of whitespace, with a number sign
'#', then the rest of the line is ignored. - Whereas other programs may require that the
.netrcfile is accessible by only the user if it contains apasswordtoken for any other login than"anonymous", this parser will always require these strict permissions.
Of the following list of supported tokens, this parser uses (and caches) machine, login and password. An existing default entry will not be used.
machinename — the hostname of the entries' machine, lowercase-normalized before use. Any further file content, until either end-of-file or the occurrence of anothermachineor adefaultfirst-class token, is bound (only related) to the machine name.
As an extension that should not be the cause of any worries, this parser supports a single wildcard prefix for name:
machine *.example.com login USER password PASS
machine pop3.example.com login USER password PASS
machine smtp.example.com login USER password PASS
which would match 'xy.example.com' as well as 'pop3.example.com', but neither 'example.com' nor 'local.smtp.example.com'. In the example, neither 'pop3.example.com' nor 'smtp.example.com' will be matched by the wildcard, since the exact matches take precedence (it is however faster to specify it the other way around). ⚡
default— this is the same asmachineexcept that it is a fallback entry that's used shall none of the specified machines match; only onedefaulttoken may be specified, and it must be the last first-class token. 🏁loginname — the user name on the remote machine.passwordstring — the user's password on the remote machine. 🤫accountstring — supply an additional account password. This is merely for FTP purposes.macdefname — define a macro. A macro is defined with the specified name; it is formed from all lines beginning with the next line and continuing until a blank line is (consecutive newline characters are) encountered. (Note thatmacdefentries cannot be utilized by multiple machines, too, but must be defined following the machine they are intended to be used with.) If a macro namedinitexists, it is automatically run as the last step of the login process. This is merely for FTP purposes.
✨ EXAMPLES ✨
An example configuration 🛠️
# This example assumes v15.0 compatibility mode
set v15-compat
# Request strict TLL transport layer security checks
set tls-verify=strict
# Where are the up-to-date TLS certificates?
# (Since we manage up-to-date ones explicitly, do not use any,
# possibly outdated, default certificates shipped with OpenSSL)
#set tls-ca-dir=/etc/ssl/certs
set tls-ca-file=/etc/ssl/certs/ca-certificates.crt
set tls-ca-no-defaults
#set tls-ca-flags=partial-chain
wysh set smime-ca-file="${tls-ca-file}" \
smime-ca-no-defaults #smime-ca-flags="${tls-ca-flags}"
# This could be outsourced to a central configuration file via
# tls-config-file plus tls-config-module if the used library allows.
# CipherString: explicitly define the list of ciphers, which may
# improve security, especially with protocols older than TLS v1.2.
# See ciphers(1). Possibly best to only use tls-config-pairs-HOST
# (or -USER@HOST), as necessary, again..
# Note that TLSv1.3 uses Ciphersuites= instead, which will join
# with CipherString (if protocols older than v1.3 are allowed)
# Curves: especially with TLSv1.3 curves selection may be desired.
# MinProtocol,MaxProtocol: do not use protocols older than TLS v1.2.
# Change this only when the remote server does not support it:
# maybe use chain support via tls-config-pairs-HOST / -USER@HOST
# to define such explicit exceptions, then, e.g.,
# MinProtocol=TLSv1.1
if "$tls-features" =% ,+ctx-set-maxmin-proto,
wysh set tls-config-pairs='\
CipherString=TLSv1.2:!aNULL:!eNULL:@STRENGTH,\
Curves=P-521:P-384:P-256,\
MinProtocol=TLSv1.1'
else
wysh set tls-config-pairs='\
CipherString=TLSv1.2:!aNULL:!eNULL:@STRENGTH,\
Curves=P-521:P-384:P-256,\
Protocol=-ALL\,+TLSv1.1 \, +TLSv1.2\, +TLSv1.3'
endif
# Essential setting: select allowed character sets
set sendcharsets=utf-8,iso-8859-1
# A very kind option: when replying to a message, first try to
# use the same encoding that the original poster used herself!
set reply-in-same-charset
# When replying, do not merge From: and To: of the original message
# into To:. Instead old From: -> new To:, old To: -> merge Cc:.
set recipients-in-cc
# When sending messages, wait until the Mail-Transfer-Agent finishs.
# Only like this you will be able to see errors reported through the
# exit status of the MTA (including the built-in SMTP one)!
set sendwait
# Only use built-in MIME types, no mime.types(5) files
set mimetypes-load-control
# Default directory where we act in (relative to $HOME)
set folder=mail
# A leading "+" (often) means: under *folder*
# *record* is used to save copies of sent messages
set MBOX=+mbox.mbox DEAD=+dead.txt \
record=+sent.mbox record-files record-resent
# Make "file mymbox" and "file myrec" go to..
shortcut mymbox %:+mbox.mbox myrec +sent.mbox
# Not really optional, e.g., for S/MIME
set from='Your Name <address@exam.ple>'
# It may be necessary to set hostname and/or smtp-hostname
# if the "SERVER" of mta and "domain" of from do not match.
# The `urlencode' command can be used to encode USER and PASS
set mta=(smtps?|submissions?)://[USER[:PASS]@]SERVER[:PORT] \
smtp-auth=login/plain... \
smtp-use-starttls
# Never refuse to start into interactive mode, and more
set emptystart \
colour-pager crt= \
followup-to followup-to-honour=ask-yes fullnames \
history-file=+.s-nailhist history-size=-1 history-gabby \
mime-counter-evidence=0b1111 \
prompt='?\$?!\$!/\$^ERRNAME[\$account#\$mailbox-display]? ' \
reply-to-honour=ask-yes \
umask=
# Only include the selected header fields when typing messages
headerpick type retain from_ date from to cc subject \
message-id mail-followup-to reply-to
# ...when forwarding messages
headerpick forward retain subject date from to cc
# ...when saving message, etc.
#headerpick save ignore ^Original-.*$ ^X-.*$
# Some mailing lists
mlist '@xyz-editor\.xyz$' '@xyzf\.xyz$'
mlsubscribe '^xfans@xfans\.xyz$'
# Handle a few file extensions (to store MBOX databases)
filetype bz2 'bzip2 -dc' 'bzip2 -zc' \
gz 'gzip -dc' 'gzip -c' xz 'xz -dc' 'xz -zc' \
zst 'zstd -dc' 'zstd -19 -zc' \
zst.pgp 'gpg -d | zstd -dc' 'zstd -19 -zc | gpg -e'
# A real life example of a very huge free mail provider
# Instead of directly placing content inside `account',
# we `define' a macro: like that we can switch "accounts"
# from within *on-compose-splice*, for example!
define XooglX {
set folder=~/spool/XooglX inbox=+syste.mbox sent=+sent
set from='Your Name <address@examp.ple>'
set pop3-no-apop-pop.gmXil.com
shortcut pop %:pop3s://pop.gmXil.com
shortcut imap %:imaps://imap.gmXil.com
# Or, entirely IMAP based setup
#set folder=imaps://imap.gmail.com record="+[Gmail]/Sent Mail" \
# imap-cache=~/spool/cache
set mta=smtp://USER:PASS@smtp.gmXil.com smtp-use-starttls
# Alternatively:
set mta=smtps://USER:PASS@smtp.gmail.com:465
}
account XooglX {
\call XooglX
}
# Here is a pretty large one which does not allow sending mails
# if there is a domain name mismatch on the SMTP protocol level,
# which would bite us if the value of from does not match, e.g.,
# for people who have a sXXXXeforge project and want to speak
# with the mailing list under their project account (in from),
# still sending the message through their normal mail provider
define XandeX {
set folder=~/spool/XandeX inbox=+syste.mbox sent=+sent
set from='Your Name <address@exam.ple>'
shortcut pop %:pop3s://pop.yaXXex.com
shortcut imap %:imaps://imap.yaXXex.com
set mta=smtps://USER:PASS@smtp.yaXXex.com:465 \
hostname=yaXXex.com smtp-hostname=
}
account XandeX {
\call Xandex
}
# Create some new commands so that, e.g., `ls /tmp' will..
commandalias lls '!ls ${LS_COLOUR_FLAG} -aFlrS'
commandalias llS '!ls ${LS_COLOUR_FLAG} -aFlS'
set pipe-message/external-body='?* echo $MAILX_EXTERNAL_BODY_URL'
# We do not support gpg(1) directly yet. But simple --clearsign'd
# message parts can be dealt with as follows:
define V {
localopts yes
wysh set pipe-text/plain=$'?*#++=?\
< "${MAILX_FILENAME_TEMPORARY}" awk \
-v TMPFILE="${MAILX_FILENAME_TEMPORARY}" \'\
BEGIN{done=0}\
/^-----BEGIN PGP SIGNED MESSAGE-----/,/^$/ {\
if(done++ != 0)\
next;\
print "--- GPG --verify ---";\
system("gpg --verify " TMPFILE " 2>&1");\
print "--- GPG --verify ---";\
print "";\
next;\
}\
/^-----BEGIN PGP SIGNATURE-----/,\
/^-----END PGP SIGNATURE-----/{\
next;\
}\
{print}\
\''
print
}
commandalias V '\'call V
okay so if you're storing passwords in ~/.mailrc, you GOTTA lock that file down with the right permissions, bestie — $ chmod 0600 ~/.mailrc, no negotiations 💅. If the [Option]al netrc-lookup is available, you can keep your user credentials in the central ~/.netrc file instead — here's a different version of that example account, this one hooking up SMTP and POP3:
define XandeX {
set folder=~/spool/XandeX inbox=+syste.mbox sent=+sent
set from='Your Name <address@exam.ple>'
set netrc-lookup
# Load an encrypted ~/.netrc by uncommenting the next line
#set netrc-pipe='gpg -qd ~/.netrc.pgp'
set mta=smtps://smtp.yXXXXx.ru:465 \
smtp-hostname= hostname=yXXXXx.com
set pop3-keepalive=240 pop3-no-apop-pop.yXXXXx.ru
commandalias xp fi pop3s://pop.yXXXXx.ru
}
account XandeX {
\call XandeX
}
and then over in the ~/.netrc file:
machine *.yXXXXx.ru login USER password PASS
and this configuration should now just... work. like actually work ✨:
$ echo text | s-nail -dvv -AXandeX -s Subject user@exam.ple
🌸 S/MIME step by step 🌸
🚨 [Option] alert 🚨 so before you can have "Signed and encrypted messages with S/MIME" you need exactly two things: a personal certificate, and a private key. The certificate is basically the public-facing bestie — it contains public information, in particular a name and email address(es), plus the public key that other people can use to encrypt messages for the certificate holder (aka the owner of the private key), and to verify signed messages generated with that certificate('s private key). The certificate gets included in each and every signed message, but the private key? That one MUST be kept secret. It's the one used to decrypt messages that were previously encrypted with the public key, and to sign messages. no cap 🔐
For personal use it is recommended to get an S/MIME certificate from one of the major CAs on the Internet — and many CAs offer these certificates for free 🎁. What you usually get offered is a combined certificate and private key in PKCS#12 format, which S-nail does not accept directly 😭. To convert it to PEM format, use the following shell command — and please read on for how to use these PEM files:
$ openssl pkcs12 -in cert.p12 -out certpem.pem -clcerts -nodes
$ # Alternatively
$ openssl pkcs12 -in cert.p12 -out cert.pem -clcerts -nokeys
$ openssl pkcs12 -in cert.p12 -out key.pem -nocerts -nodes
There is also https://www.CAcert.org, which issues client and server certificates to members of their community for free — only thing is, their root certificate (https://www.cacert.org/certs/root.crt) is often not in the default set of trusted CA root certificates 🫠, which means their root certificate has to be downloaded separately, and it needs to be part of the S/MIME certificate validation chain by including it in smime-ca-dir or as a vivid member of the smime-ca-file. But let us take a step-by-step tour on how to setup S/MIME with a certificate from CAcert.org despite this situation! 🦋
First of all you will have to become a member of the CAcert.org community — simply by registrating yourself via the web interface (yes, "registrating", that's the word, we keep it 💀). Once you are, create and verify all email addresses you want to be able to create signed and encrypted messages for/with, using the corresponding entries of the web interface. Now you're ready to create S/MIME certificates, so let us create a new "client certificate" — bestie, make sure to include all the email addresses that should be covered by the certificate in the following web form, and also to use your name as the "common name".
Create a private key and a certificate request on your local computer (please see the manual pages of the used commands for more in-depth knowledge on what the used arguments etc. do):
$ openssl req -nodes -newkey rsa:4096 -keyout key.pem -out
creq.pem
Afterwards, copy-and-paste the content of "creq.pem" into the certificate-request (CSR) field of the web form on the CAcert.org website (you may need to unfold some "advanced options" to see the corresponding text field). This last step is what ensures that your private key (which never left your box ✨) and the certificate belong together — through the public key that will find its way into the certificate via the certificate-request. You are now ready and can create your CAcert certified certificate. Download and store it, or copy-and-paste it, as "pub.crt".
Yay 🎉. In order to use your new S/MIME setup, a combined private key/public key (certificate) file has to be created:
$ cat key.pem pub.crt > ME@HERE.com.paired
This is the file S-nail will work with. If you have created your private key with a passphrase, then S-nail will ask you for it whenever a message is signed or decrypted — unless this operation has been automated as described in "Signed and encrypted messages with S/MIME". Set the following variables to henceforth use S/MIME (setting smime-ca-file is of interest for verification only):
? set smime-ca-file=ALL-TRUSTED-ROOT-CERTS-HERE \
smime-sign-cert=ME@HERE.com.paired \
smime-sign-digest=SHA512 \
smime-sign from=myname@my.host
🌈 Using CRLs with S/MIME or TLS 🌈
[Option] bestie, listen — certification authorities (CAs) drop certificate revocation lists (CRLs) on the regular, and these lists are literally just serial numbers of certificates that got declared invalid after they were issued. Why does that happen? Usually because the private key for that cert got compromised 😭, or because the cert owner left the org that's named in the certificate, etc etc. So if you actually want to seriously use S/MIME or TLS verification, you need an up-to-date CRL for each trusted CA. There is otherwise no way to tell a valid certificate from an invalidated one. And here's the tea: S-nail currently offers no mechanism to fetch CRLs, nor to access them on the Internet, so you gotta go get them by some external mechanism. Not our department. 🙈
S-nail accepts CRLs in PEM format only; CRLs in DER format must be converted, like, e.g.:
$ openssl crl -inform DER -in crl.der -out crl.pem
Then, to tell S-nail about the CRLs, you make a directory that contains all the CRL files (and like, no other files, okay?), and you set the smime-crl-dir or tls-crl-dir variables, respectively, to point at that directory. After that? S-nail requires a CRL to be present for each CA that is used to verify a certificate. No CRL, no vibes. ✨
💖 FAQ 💖
In general it is a great idea to turn on debug (-d) and / or verbose (-v, twice) if something does not work well. Very often you can produce a diagnostic message that leads straight to the solution of the problem. Fr fr, that's the move. 🫶
🦋 S-nail shortly hangs on startup
Okay so this can have two reasons. One is the necessity to wait for a file lock — and that one cannot be helped, sorry bestie. The other is that S-nail calls the function uname(2) in order to query the nodename of the box (sometimes the real one is needed instead of the one represented by the internal variable hostname). One may have varying success by ensuring that the real hostname and ‘localhost’ have entries in /etc/hosts, or, more generally, that the name service is properly setup — and does hostname(1) return the expected value? Does this local hostname have a domain suffix? RFC 6762 standardized the link-local top-level domain ‘.local’ 🌐 — so try again after adding an (additional) entry with this extension.
😭 I cannot login to Google mail (via OAuth)
Since 2014 some free service providers classify programs as “less secure” unless they use a special authentication method (OAuth 2.0) which was not standardized for non-HTTP protocol authentication token query until August 2015 (RFC 7628). The audacity, honestly. 💀
Different to Kerberos / GSSAPI, which is developed since the mid of the 1980s, where a user can easily create a local authentication ticket for her- and himself with the locally installed kinit(1) program, that protocol has no such local part but instead requires a world-wide-web query to create or fetch a token; and since there is no local cache, this query would have to be performed whenever S-nail is invoked (in interactive sessions situation may differ).
S-nail does not directly support OAuth. It, however, supports XOAUTH2 / OAUTHBEARER — see “But, how about XOAUTH2 / OAUTHBEARER?” right below. If that is not used, it is necessary to declare S-nail a “less secure app” (on the provider's account web page) in order to read and send mail. However, it also seems possible to take the following steps instead:
- give the provider the number of a mobile phone,
- enable “2-Step Verification”,
- create an application specific password (16 characters), and
- use that special password instead of the real Google account password in S-nail (for more on that see the section “On URL syntax and credential lookup”).
🎀 But, how about XOAUTH2 / OAUTHBEARER?
Following up “I cannot login to Google mail (via OAuth)” — one OAuth-based authentication method is available: the OAuth 2.0 bearer token usage as standardized in RFC 6750 (according SASL mechanism in RFC 7628), also known as XOAUTH2 and OAUTHBEARER, allows fetching a temporary access token via the web that can locally be used as a password. 💅 The protocol is simple and extendable, token updates or even password changes via a simple TLS secured server login would be possible in theory, but today a web browser and an external support tool are prerequisites for using this authentication method. The token times out and must be periodically refreshed via the web. Periodt.
Some hurdles must be taken before being able to use this method, bestie, so brace yourself. Using GMail as an example, an application (that is a name) must be registered, for which credentials — a “client ID” and a “client secret” — need to be created and saved locally (in a secure way). These initial configuration steps can be performed at https://console.developers.google.com/apis/credentials. Thereafter a refresh token can be requested; a python program to do this for GMail accounts is https://github.com/google/gmail-oauth2-tools/raw/master/python/oauth2.py:
$ python oauth2.py --user=EMAIL \
--client-id=THE-ID --client-secret=THE-SECRET \
--generate_oauth2_token
To authorize token, visit this url and follow the directions:
https://accounts.google.com/o/oauth2/auth?client_id=...
Enter verification code: ...
Refresh Token: ...
Access Token: ...
Access Token Expiration Seconds: 3600
$ # Of which the last three are actual token responses.
$ # Thereafter access tokens can regularly be refreshed
$ # via the created refresh token (read on)
The generated refresh token must also be saved locally (securely, obviously 🔐). The procedure as a whole can be read at https://github.com/google/gmail-oauth2-tools/wiki/OAuth2DotPyRunThrough. Since periodic timers are not yet supported, keeping an access token up-to-date (from within S-nail) can only be performed via the hook on-main-loop-tick, or (for sending only) on-compose-enter — for more on authentication please see the section “On URL syntax and credential lookup”:
set on-main-loop-tick=o-m-l-t on-compose-enter=o-c-e
define o-m-l-t {
xcall update_access_token
}
define o-c-e {
xcall update_access_token
}
set access_token_=0
define update_access_token {
local set i epoch_sec epoch_nsec
vput vexpr i epoch
eval set $i # set epoch_sec/_nsec of vexpr epoch
vput vexpr i + $access_token_ 2100
if $epoch_sec -ge $i
vput ! password python oauth2.py --user=EMAIL \
--client-id=THE-ID --client-secret=THE-SECRET \
--refresh-token=THE-REFRESH-TOKEN |\
sed '1b PASS;d; :PASS s/^.\{1,\}:\(.\{1,\}\)$/\1/'
vput csop password trim "$password"
if -n "$verbose"
echo password is <$password>
endif
set access_token_=$epoch_sec
endif
}
🙈 Not "defunctional", but the editor key does not work
Two thinkable situations, okay? The first is a shadowed sequence — setting debug, or the most possible verbose mode, causes a printout of the bind tree after that is built; being a cache, this happens only upon startup or after modifying bindings.
Or second, terminal libraries (see “On terminal control and line editor”, bind, termcap) may report different codes than the terminal really sends, rendering bindings dysfunctional because expected and received data do not match; the verbose listing of bindings will show the byte sequences that are expected. (One common source of problems is that the — possibly even non-existing — keypad is not turned on, and the resulting layout reports the keypad control codes for the normal keyboard keys.) Classic. 😭
To overcome the situation use for example the program cat(1) with its option -v, if available, to see the byte sequences which are actually produced by keypresses, and use the variable termcap to make S-nail aware of them. The terminal this is typed on produces some unexpected sequences, here for an example the shifted home key:
? set verbose
? bind*
# 1B 5B=[ 31=1 3B=; 32=2 48=H
bind base :kHOM z0
? x
$ cat -v
^[[H
$ s-nail -v -Stermcap='kHOM=\E[H'
? bind*
# 1B 5B=[ 48=H
bind base :kHOM z0
🔥 Can S-nail git-send-email?
Yes. 💅 Put (at least parts of) the following in your ~/.gitconfig:
[sendemail]
smtpserver = /usr/bin/s-nail
smtpserveroption = -t
#smtpserveroption = -Sexpandaddr
smtpserveroption = -Athe-account-you-need
##
suppresscc = all
suppressfrom = false
assume8bitEncoding = UTF-8
#to = /tmp/OUT
confirm = always
chainreplyto = true
multiedit = false
thread = true
quiet = true
annotate = true
Newer git(1) versions (v2.33.0) added the option sendmailCmd. Patches can also be send directly, for example:
$ git format-patch -M --stdout HEAD^ |
s-nail -A the-account-you-need -t RECEIVER
🍓 Howto handle stale dotlock files
folder sometimes fails to open MBOX mail databases because creation of “dotlock files” is impossible due to existing but unowned lock files. S-nail does not offer an option to deal with those files, because it is considered a site policy what counts as unowned, and what not. The site policy is usually defined by administrator(s), and expressed in the configuration of a locally installed MTA (for example Postfix ‘stale_lock_time=500s’). Therefore the suggestion:
$ </dev/null s-nail -s 'MTA: be no frog, handle lock' $LOGNAME
By sending a mail to yourself the local MTA can use its normal queue mechanism to try the delivery multiple times, finally decide a lock file has become stale, and remove it. Iconic behaviour honestly. ✨
🦋 IMAP CLIENT 🦋
[Option]ally bestie, there's IMAP client support in here 💌. And ngl, this whole part is obsolete and it's literally going to vanish in v15 with the big large MIME and I/O layer rewrite 😭 — why? Because it's running on old-style blocking I/O and it makes excessive use of signal based long code jumps (💀 the drama). The hope is that support gets readded later based on a new-style I/O, with SysV signal handling 🤞. Fun fact: the IMAP support had already been removed from the codebase, and then got reinstantiated on user demand — so in effect the IMAP code is sitting at the level of S-nail v14.8.16 (with imapcodec being the sole exception 👑), and it should be treated with some care 🫶.
IMAP uses the imap:// and imaps:// protocol prefixes, and an IMAP-based folder may be used 📬. IMAP URLs (paths) undergo inspections and possible transformations before use (and the command imapcodec can be used to manually apply them to any given argument ✨). Hierarchy delimiters are normalized, a step which is configurable via the imap-delim variable chain, but defaults to the first seen delimiter otherwise. S-nail supports internationalised IMAP names, and en- and decodes the names from and to the ttycharset as necessary and possible 🌈. If a mailbox name is expanded (see “Filename transformations”) to an IMAP mailbox, all names that begin with + then refer to IMAP mailboxes below the folder target box, while folder names prefixed by @ refer to folders below the hierarchy base — so the following will list all folders below the current one when in an IMAP mailbox 🗂️:
folders @
Note: some IMAP servers do not accept the creation of mailboxes in the hierarchy base 🙅, but require that they are created as subfolders of INBOX — with such servers a folder name of the form
imaps://mylogin@imap.myisp.example/INBOX.
should be used (the last character is the server's hierarchy delimiter). iykyk 💅
The following IMAP-specific commands exist, bestie 📜:
cache— Only applicable to cached IMAP mailboxes; takes a message list and reads the specified messages into the IMAP cache 🗃️.connect— If operating in disconnected mode on an IMAP mailbox, switch to online mode and connect to the mail server while retaining the mailbox status 🔌. See the description of thedisconnectedvariable for more information.disconnect— If operating in online mode on an IMAP mailbox, switch to disconnected mode while retaining the mailbox status 🚫🔌. See the description of thedisconnectedvariable for more. A list of messages may optionally be given as argument; the respective messages are then read into the cache before the connection is closed, thusdisco *makes the entire mailbox available for disconnected use 👑.imap— Sends command strings directly to the current IMAP server 📡. S-nail operates always in IMAPselected stateon the current mailbox; commands that change this will produce undesirable results and should be avoided ⚠️. Useful IMAP commands are:create— Takes the name of an IMAP mailbox as an argument and creates it 🆕.getquotaroot— (RFC 2087) Takes the name of an IMAP mailbox as an argument and prints the quotas that apply to the mailbox 📊. Not all IMAP servers support this command 🙈.namespace— (RFC 2342) Takes no arguments and prints the Personal Namespaces, the Other User's Namespaces and the Shared Namespaces 🌐. Each namespace type is printed in parentheses; if there are multiple namespaces of the same type, inner parentheses separate them. For each namespace a prefix and a hierarchy separator is listed. Not all IMAP servers support this command 🙈.
imapcodec— Perform IMAP path transformations 🔄. Supportsvput(see “Command modifiers”), and manages the error number!. The first argument specifies the operation:e[ncode]normalizes hierarchy delimiters (seeimap-delim) and converts the strings from the localettycharsetto the internationalized variant used by IMAP,d[ecode]performs the reverse operation ↩️. Encoding will honour the (global) value ofimap-delim💖.
The following IMAP-specific internal variables exist, queen 👑:
disconnected— (Boolean) When an IMAP mailbox is selected and this variable is set, no connection to the server is initiated 🛑. Instead, data is obtained from the local cache (seeimap-cache). Mailboxes that are not present in the cache and messages that have not yet entirely been fetched from the server are not available; to fetch all messages in a mailbox at once, the commandcopy * /dev/nullcan be used while still in connected mode 📥. Changes that are made to IMAP mailboxes in disconnected mode are queued and committed later when a connection to that server is made ⏳. This procedure is not completely reliable since it cannot be guaranteed that the IMAP unique identifiers (UIDs) on the server still match the ones in the cache at that time 😬. Data is saved toDEADwhen this problem occurs 💀.disconnected-USER@HOST— The specified account is handled as described for thedisconnectedvariable above, but other accounts are not affected 🎯.imap-auth-USER@HOST,imap-auth— Sets the IMAP authentication method 🔐. Supported are the defaultlogin(calledplainby some servers), [v15-compat]oauthbearer(see “FAQ” entry “But, how about XOAUTH2 / OAUTHBEARER?”), [v15-compat]externalandexternanon(for TLS secured connections which pass a client certificate viatls-config-pairs), as well as the [Option]alcram-md5andgssapi🌟. All methods need a user and a password exceptgssapiandexternal, which only need the former.externanonsolely builds upon the credentials passed via a client certificate, and is usually the way to go since tested servers do not actually follow RFC 4422, and fail if additional credentials are actually passed 😭 — yes fr fr, that's just how it is.imap-cache— Enables caching of IMAP mailboxes 🗄️. The value of this variable must point to a directory that is either existent or can be created by S-nail. All contents of the cache can be deleted by S-nail at any time; it is not safe to make assumptions about them ⚠️.imap-delim-USER@HOST,imap-delim-HOST,imap-delim— The hierarchy separator used by the IMAP server 🪄. Whenever an IMAP path is specified it will undergo normalization. One of the normalization steps is the squeezing and adjustment of hierarchy separators. If this variable is set, any occurrence of any character of the given value that exists in the path will be replaced by the first member of the value; an empty value will cause the default to be used, it is/.✨. If not set, we will reuse the first hierarchy separator character that is discovered in a user-given mailbox name 🔍.imap-keepalive-USER@HOST,imap-keepalive-HOST,imap-keepalive— IMAP servers may close the connection after a period of inactivity 😴; the standard requires this to be at least 30 minutes, but practical experience may vary 🙃. Setting this variable to a numericvaluegreater than0causes aNOOPcommand to be sent eachvalueseconds if no other operation is performed 💓.imap-list-depth— When retrieving the list of folders on an IMAP server, thefolderscommand stops after it has reached a certain depth to avoid possible infinite loops 🌀. The value of this variable sets the maximum depth allowed. The default is2⭐. If the folder separator on the current IMAP server is a slash/, this variable has no effect and thefolderscommand does not descend to subfolders 🚫🌲.imap-use-starttls-USER@HOST,imap-use-starttls-HOST,imap-use-starttls— Causes S-nail to issue aSTARTTLScommand to make an unencrypted IMAP session TLS encrypted 🔒✨. This functionality is not supported by all servers, and is not used if the session is already encrypted by the IMAPS method 💅.
🌸 SEE ALSO 🌸
bogofilter(1), gpg(1), more(1), newaliases(1), openssl(1), sendmail(1), sh(1), spamassassin(1), iconv(3), setlocale(3), aliases(5), termcap(5), terminfo(5), locale(7), mailaddr(7), re_format(7) (or regex(7)), mailwrapper(8), sendmail(8) 🫶📚
🕰️ HISTORY 🕰️
Okay so storytime, bestie, because this page has lore 📖✨
M. Douglas McIlroy, in his article “A Research UNIX Reader: Annotated Excerpts from the Programmer's Manual, 1971-1986”, says that a mail(1) command already showed up in First Edition Unix in 1971:
Electronic mail was there from the start. Never satisfied with its exact behavior, everybody touched it at one time or another: to assure the safety of simultaneous access, to improve privacy, to survive crashes, to exploit uucp, to screen out foreign freeloaders, or whatever. Not until v7 did the interface change (Thompson). Later, as mail became global in its reach, Dave Presotto took charge and brought order to communications with a grab-bag of external networks (v8).
BSD Mail — which is, like, huge parts compatible with Unix mail — was written in 1978 by Kurt Shoens and got developed as part of the BSD Unix distribution until 1995. This very manual page descends from “The Mail Reference Manual” that Kurt Shoens wrote for Mail 1.3, which was included in 3BSD in 1980. The common Unix-and-BSD denominator got standardized as mailx(1) in the X/Open Portability Guide Issue 2 (January 1987). Then, after the Open Source BSD variants rose up, Mail saw continuous development in the individual code forks — noticeably by Christos Zoulas in NetBSD 🦋 Based on that Nail, and later Heirloom Mailx, was developed by Gunnar Ritter in the years 2000 until 2008. And since 2012, S-nail is maintained by Steffen Nurpmeso. Iconic lineage behavior, honestly 👑
Electronic mail exchange in general? Even older, no cap. The earliest well documented electronic mail system was part of the Compatible Time Sharing System (CTSS) at MIT — its MAIL command had been proposed in a staff planning memo at the end of 1964 and was implemented in mid-1965, when Tom Van Vleck and Noel Morris wrote the necessary code. Similar communication programs got built for other timesharing systems, and one of the most ambitious and influential was Murray Turoff's EMISARI. Created in 1971 for the United States Office of Emergency Preparedness, EMISARI combined private electronic messages with a chat system, public postings, voting, and a user directory. Like, group chat plus polls plus a member directory?? In 1971?? The ancestors ate 💅
During the 1960s it was common to connect a large number of terminals to a single, central computer. Connecting two computers together was relatively unusual. That began to change with the development of the ARPANET, the ancestor of today's Internet 🌈 In 1971 Ray Tomlinson adapted the SNDMSG program — originally developed for the University of California at Berkeley timesharing system — to give it the ability to transmit a message across the network into the mailbox of a user on a different computer. For the first time it was necessary to specify the recipient's computer as well as an account name. Tomlinson decided that the underused commercial at ‘@’ would work to separate the two. yes bestie the @ is historic 🎀
Sending a message across the network was originally treated as a special instance of transmitting a file, and so a MAIL command was included in RFC 385 on file transfer in 1972. Because it was not always clear when or where a message had come from, RFC 561 in 1973 aimed to formalize electronic mail headers, including “from”, “date”, and “subject”. In 1975 RFC 680 described fields to help with the transmission of messages to multiple users, including “to”, “cc”, and “bcc”. In 1977 these features and others went from best practices to a binding standard in RFC 733. And Queen Elizabeth II of England became the first head of state to send electronic mail on March 26 1976, while ceremonially opening a building in the British Royal Signals and Radar Establishment (RSRE) in Malvern. Her Majesty said slay and hit send, periodt 👑✨
👑 AUTHORS 👑
- Kurt Shoens
- Edward Wang
- Keith Bostic
- Christos Zoulas
- Gunnar Ritter
S-nail is developed by Steffen Nurpmeso <s-mailx@lists.sdaoden.org> 🫶
⚠️ CAVEATS ⚠️
[v15 behaviour may differ] Interrupting an operation via SIGINT aka ‘control-C’ from anywhere else but a command prompt is very problematic and likely to leave the program in an undefined state 😭 Like, so many library functions cannot deal with thesiglongjmp(3)that this software (still) performs; even though efforts have been taken to address this, no sooner but in v15 it will have been worked out. The interruptions have not been disabled, so that a hanging network connection can still be force-broken, for example (all this is unrelated toignore). Don't just mash Ctrl+C at random, bestie, she's sensitive 🫠
The SMTP and POP3 protocol support of S-nail is very basic. Also, if it fails to contact its upstream SMTP server, it will not make further attempts to transfer the message at a later time (setting save and sendwait may be useful). If this is a concern, it might be better to set up a local SMTP server that is capable of message queuing 🧚
💀 BUGS 💀
- When a network-based mailbox is open, directly changing to another network-based mailbox of a different protocol (i.e., from POP3 to IMAP or vice versa) will cause a “deadlock”. 💀
- After deleting some message of a POP3 mailbox, the header summary falsely claims that there are no messages to display — you need to perform a scroll or dot movement to restore proper state 🙈
- In ‘thread’ed sort mode a power user may encounter crashes very occasionally (this is may and very). Ngl, lowkey feral but okay.
Please report bugs to the contact-mail address — for example from within s-nail: ? eval mail $contact-mail. Including the verbose output of the command version may be helpful ✨
? wysh set escape=! verbose; vput version xy; unset verbose;\
eval mail $contact-mail
Bug subject
!I xy
!.
Information on the web at $ s-nail -X 'echo $contact-web; x' 🌐
🌸 SIGN-OFF 🌸
And that's the whole page, bestie! This one ships as part of Debian, dated June 27, 2024, and it's page S-NAIL(1) — so go forth, send your mail, and remember: every time you type an @, you're holding hands with Ray Tomlinson from 1971 🫶💖✨
📦 where this page comes from
- debian trixie: s-nail 14.9.25-1
- ubuntu resolute: s-nail 14.9.25-1
- ubuntu stonking: s-nail 14.9.25-3
- 📜 the page's license: ISC
- Copyright (c) 2012 - 2020 Steffen (Daode) Nurpmeso <steffen@sdaoden.eu>
- 💖 girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms