MAILX(1POSIX)

๐ŸŽ€ MAILX(1POSIX) โ€” POSIX Programmer's Manual ๐ŸŽ€

hiii bestie ๐Ÿ’– okay so we're doing the mailx page, straight from the POSIX Programmer's Manual. it's a long one so buckle up, grab a boba, and let's get into it. no cap, every single detail stays. periodt.


๐ŸŒธ PROLOG ๐ŸŒธ

This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux.

translation for the girlies: this is the POSIX spec version, not the Linux one. Linux might do it differently (go read the Linux page for the deets) or might not even have it at all. ๐Ÿ’€

๐Ÿ’– NAME ๐Ÿ’–

mailx โ€” process messages

like, that's the whole job description. she processes messages. iconic behavior honestly. ๐Ÿ‘‘


โœจ SYNOPSIS โœจ

๐Ÿ’Œ Send Mode

mailx [-s subject] address...

๐Ÿ’Œ Receive Mode

mailx -e
mailx [-HiNn] [-F] [-u user]
mailx -f [-HiNn] [-F] [file]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

The mailx utility provides a message sending and receiving facility. It has two major modes, selected by the options used: Send Mode and Receive Mode.

On systems that do not support the User Portability Utilities option, an application using mailx shall have the ability to send messages in an unspecified manner (Send Mode). Unless the first character of one or more lines is <tilde> ('~'), all characters in the input message shall appear in the delivered message, but additional characters may be inserted in the message before it is retrieved.

On systems supporting the User Portability Utilities option, mail-receiving capabilities and other interactive features, Receive Mode, described below, also shall be enabled.

๐Ÿ’Œ Send Mode

Send Mode can be used by applications or users to send messages from the text in standard input.

๐Ÿ’Œ Receive Mode

Receive Mode is more oriented towards interactive users. Mail can be read and sent in this interactive mode.

When reading mail, mailx provides commands to facilitate saving, deleting, and responding to messages. When sending mail, mailx allows editing, reviewing, and other modification of the message as it is entered.

Incoming mail shall be stored in one or more unspecified locations for each user, collectively called the system mailbox for that user. When mailx is invoked in Receive Mode, the system mailbox shall be the default place to find new mail. As messages are read, they shall be marked to be moved to a secondary file for storage, unless specific action is taken. This secondary file is called the mbox and is normally located in the directory referred to by the HOME environment variable (see MBOX in the ENVIRONMENT VARIABLES section for a description of this file). Messages shall remain in this file until explicitly removed. When the -f option is used to read mail messages from secondary files, messages shall be retained in those files unless specifically removed. All three of these locationsโ€”system mailbox, mbox, and secondary fileโ€”are referred to in this section as simply "mailboxes", unless more specific identification is required.

so like. three spots can hold your mail: the system mailbox, the mbox, and any secondary file you point at with -f. that's the whole "mailbox" thing, iykyk. ๐Ÿซถ

๐Ÿ’… OPTIONS ๐Ÿ’…

The mailx utility shall conform to the Base Definitions volume of POSIX.1โ€2017, Section 12.2, Utility Syntax Guidelines.

The following options shall be supported. (Only the -s subject option shall be required on all systems. The other options are required only on systems supporting the User Portability Utilities option.)

  • -e โ€” Test for the presence of mail in the system mailbox. The mailx utility shall write nothing and exit with a successful return code if there is mail to read. (silent queen behavior โ€” says nothing, just succeeds if there's mail ๐Ÿ’…)
  • -f โ€” Read messages from the file named by the file operand instead of the system mailbox. (See also folder.) If no file operand is specified, read messages from mbox instead of the system mailbox.
  • -F โ€” Record the message in a file named after the first recipient. The name is the login-name portion of the address found first on the To: line in the mail header. Overrides the record variable, if set (see Internal Variables in mailx).
  • -H โ€” Write a header summary only.
  • -i โ€” Ignore interrupts. (See also ignore.)
  • -n โ€” Do not initialize from the system default start-up file. See the EXTENDED DESCRIPTION section.
  • -N โ€” Do not write an initial header summary.
  • -s subject โ€” Set the Subject header field to subject. All characters in the subject string shall appear in the delivered message. The results are unspecified if subject is longer than {LINE_MAX} - 10 bytes or contains a <newline>.
  • -u user โ€” Read the system mailbox of the login name user. This shall only be successful if the invoking user has appropriate privileges to read the system mailbox of that user.
heads up bestie: only -s subject is required on every system. all the other options only have to exist if the system supports the User Portability Utilities option. don't @ me, that's just the spec. ๐Ÿ™ˆ

๐Ÿ“ OPERANDS ๐Ÿ“

  • address โ€” Addressee of message. When -n is specified and no user start-up files are accessed (see the EXTENDED DESCRIPTION section), the user or application shall ensure this is an address to pass to the mail delivery system. Any system or user start-up files may enable aliases (see alias under Commands in mailx) that may modify the form of address before it is passed to the mail delivery system.
  • file โ€” A pathname of a file to be read instead of the system mailbox when -f is specified. The meaning of the file option-argument shall be affected by the contents of the folder internal variable; see Internal Variables in mailx.

๐ŸŒˆ STDIN ๐ŸŒˆ

When mailx is invoked in Send Mode (the first synopsis line), standard input shall be the message to be delivered to the specified addresses. When in Receive Mode, user commands shall be accepted from stdin. If the User Portability Utilities option is not supported, standard input lines beginning with a <tilde> ('~') character produce unspecified results.

If the User Portability Utilities option is supported, then in both Send and Receive Modes, standard input lines beginning with the escape character (usually <tilde> ('~')) shall affect processing as described in Command Escapes in mailx.

the way that a <tilde> ('~') at the start of a line changes everything... if the User Portability Utilities option isn't there, those lines are unspecified โ€” literally nobody can promise what happens. ๐Ÿ˜ญ

๐Ÿงš INPUT FILES ๐Ÿงš

When mailx is used as described by this volume of POSIX.1โ€2017, the file option-argument (see the -f option) and the mbox shall be text files containing mail messages, formatted as described in the OUTPUT FILES section. The nature of the system mailbox is unspecified; it need not be a file.

ngl the plot twist here is that the system mailbox doesn't even have to be a file. it's giving mystery. ๐Ÿฆ‹

๐ŸŒธ ENVIRONMENT VARIABLES ๐ŸŒธ

Okay bestie, so some of the stuff in this section is only guaranteed on implementations that support the User Portability Utilities option, exactly as the text says, and it's not further shaded for that option. Read carefully, mkay? ๐Ÿ‘€

These env vars are the ones that shall affect how mailx runs:

  • DEAD โ€” picks the pathname of the file where partial messages get stashed when there's an interrupt or a delivery error ๐Ÿ˜ญ. The default shall be dead.letter in the directory named by the HOME variable. Warning bestie: the behavior of mailx when saving partial messages is unspecified if the User Portability Utilities option is not supported and DEAD is not defined with the value /dev/null. ๐Ÿ’€
  • EDITOR โ€” names the utility to invoke when the edit command (see Commands in mailx) or the ~e command escape (see Command Escapes in mailx) is used โœ๏ธ. The default editor is unspecified โ€” on XSI-conformant systems it is ed. The effects of this variable are unspecified if the User Portability Utilities option is not supported.
  • HOME โ€” the pathname of the user's home directory ๐Ÿ .
  • LANG โ€” provides a default value for the internationalization variables that are unset or null. (Peep the Base Definitions volume of POSIX.1โ€2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)
  • LC_ALL โ€” if set to a non-empty string value, it overrides the values of all the other internationalization variables ๐Ÿ‘‘.
  • LC_CTYPE โ€” sets the locale for interpreting sequences of bytes of text data as characters (like single-byte vs multi-byte characters in arguments and input files) and for handling case-insensitive address and header-field comparisons ๐Ÿ”ค.
  • LC_TIME โ€” this variable may determine the format and contents of the date and time strings written by mailx โฐ. This volume of POSIX.1โ€2017 specifies the effects of this variable only for systems supporting the User Portability Utilities option.
  • LC_MESSAGES โ€” sets the locale that should be used to affect the format and contents of diagnostic messages written to standard error and informative messages written to standard output ๐Ÿ’ฌ.
  • LISTER โ€” a string representing the command for writing the contents of the folder directory to standard output when the folders command is given (see folders in Commands in mailx) ๐Ÿ“. Any string acceptable as a command_string operand to the sh -c command shall be valid. If this variable is null or not set, the output command shall be ls. The effects of this variable are unspecified if the User Portability Utilities option is not supported.
  • MAILRC โ€” the pathname of the user start-up file ๐ŸŽ€. The default shall be .mailrc in the directory referred to by the HOME environment variable. Heads up: the behavior of mailx is unspecified if the User Portability Utilities option is not supported and MAILRC is not defined with the value /dev/null.
  • MBOX โ€” a pathname of the file to save messages from the system mailbox that have been read ๐Ÿ“ฌ. The exit command shall override this function, and so shall saving the message explicitly in another file. The default shall be mbox in the directory named by the HOME variable. The effects of this variable are unspecified if the User Portability Utilities option is not supported.
  • NLSPATH โ€” the location of message catalogs for the processing of LC_MESSAGES ๐Ÿ“š.
  • PAGER โ€” a string representing an output filtering or pagination command for writing the output to the terminal ๐Ÿ“„. Any string acceptable as a command_string operand to the sh -c command shall be valid. When standard output is a terminal device, the message output shall be piped through the command if the mailx internal variable crt is set to a value less than the number of lines in the message; see Internal Variables in mailx. If the PAGER variable is null or not set, the paginator shall be either more or another paginator utility documented in the system documentation. The effects of this variable are unspecified if the User Portability Utilities option is not supported.
  • SHELL โ€” the name of a preferred command interpreter ๐Ÿš. The default shall be sh. The effects of this variable are unspecified if the User Portability Utilities option is not supported.
  • TERM โ€” if the internal variable screen is not specified, this determines the name of the terminal type to indicate, in an unspecified manner, the number of lines in a screenful of headers ๐Ÿ–ฅ๏ธ. If TERM is not set or is set to null, an unspecified default terminal type shall be used and the value of a screenful is unspecified. The effects of this variable are unspecified if the User Portability Utilities option is not supported.
  • TZ โ€” this variable may determine the timezone used to calculate date and time strings written by mailx ๐ŸŒ. If TZ is unset or null, an unspecified default timezone shall be used.
  • VISUAL โ€” a pathname of a utility to invoke when the visual command (see Commands in mailx) or the ~v command escape (see Command Escapes in mailx) is used ๐Ÿ‘€. If this variable is null or not set, the full-screen editor shall be vi. The effects of this variable are unspecified if the User Portability Utilities option is not supported.

โšก ASYNCHRONOUS EVENTS โšก

When mailx is in Send Mode and standard input is not a terminal, it shall take the standard action for all signals. Simple. ๐Ÿซถ

In Receive Mode, or in Send Mode when standard input is a terminal, if a SIGINT signal is received:

  1. If in command mode, the current command, if there is one, shall be aborted, and a command-mode prompt shall be written ๐Ÿ’….
  2. If in input mode:
    • a. If ignore is set, mailx shall write "@\n", discard the current input line, and continue processing, bypassing the message-abort mechanism described in item 2b.
    • b. If the interrupt was received while sending mail, either when in Receive Mode or in Send Mode, a message shall be written, and another subsequent interrupt, with no other intervening characters typed, shall be required to abort the mail message ๐Ÿ˜ค. If in Receive Mode and another interrupt is received, a command-mode prompt shall be written. If in Send Mode and another interrupt is received, mailx shall terminate with a non-zero status.

In both cases listed in item b, if the message is not empty:

  • i. If save is enabled and the file named by DEAD can be created, the message shall be written to the file named by DEAD. If the file exists, the message shall be written to replace the contents of the file ๐Ÿ”ฅ.
  • ii. If save is not enabled, or the file named by DEAD cannot be created, the message shall not be saved ๐Ÿ’€.

The mailx utility shall take the standard action for all other signals.


๐ŸŒˆ STDOUT ๐ŸŒˆ

In command and input modes, all output โ€” prompts and messages included โ€” shall be written to standard output. Every last bit of it, periodt โœจ.


๐Ÿฉท STDERR ๐Ÿฉท

The standard error shall be used only for diagnostic messages. That's its whole job, and it's iconic for it ๐ŸŽ€.


๐Ÿฆ‹ OUTPUT FILES ๐Ÿฆ‹

So like, various mailx commands and command escapes can create or add to files โ€” the mbox, the dead-letter file, and secondary mailboxes all count ๐Ÿ“ฌ. When mailx is used as described in this volume of POSIX.1โ€2017, these files shall be text files, formatted like this:

line beginning with From<space>
[one or more header-lines; see Commands in mailx]
empty line
[zero or more body lines
empty line]
[line beginning with From<space>...]

where each message begins with the From <space> line shown, preceded by the beginning of the file or an empty line ๐Ÿ“. (The From <space> line is considered to be part of the message header, but not one of the header-lines referred to in Commands in mailx; so it shall not be affected by the discard, ignore, or retain commands โ€” no cap ๐Ÿ’….) The formats of the rest of the From <space> line and any additional header lines are unspecified, except that none shall be empty. The format of a message body line is also unspecified, except that no line following an empty line shall start with From <space>; mailx shall modify any such user-entered message body lines (following an empty line and beginning with From <space>) by adding one or more characters to precede the 'F'; it may add these characters to From <space> lines that are not preceded by an empty line.

When a message from the system mailbox or entered by the user is not a text file, it is implementation-defined how such a message is stored in files written by mailx ๐Ÿคท.


๐Ÿ‘‘ EXTENDED DESCRIPTION ๐Ÿ‘‘

The functionality in the entire EXTENDED DESCRIPTION section shall be provided on implementations supporting the User Portability Utilities option ๐ŸŒŸ. The functionality described in this section shall be provided on implementations that support the User Portability Utilities option (and the rest of this section is not further shaded for this option).

The mailx utility need not support all character encodings in all circumstances, bestie ๐Ÿ˜ญ. For example, inter-system mail may be restricted to 7-bit data by the underlying network, 8-bit data need not be portable to non-internationalized systems, and so on. Under these circumstances, it is recommended that only characters defined in the ISO/IEC 646:1991 standard International Reference Version (equivalent to ASCII) 7-bit range of characters be used ๐Ÿซถ.

Okay so bestie, when mailx gets invoked using one of the Receive Mode synopsis forms, it shall write a page of header-summary lines (if -N was not specified and there are messages, see below), followed by a prompt indicating that mailx can accept regular commands (see Commands in mailx); this is termed command mode. ๐Ÿ’… No cap, the page of header-summary lines shall contain the first new message if there are new messages, or the first unread message if there are unread messages, or the first message. When mailx is invoked using the Send Mode synopsis and standard input is a terminal, if no subject is specified on the command line and the asksub variable is set, a prompt for the subject shall be written. At this point, mailx shall be in input mode โ€” main character energy, fr fr. This input mode shall also be entered when using one of the Receive Mode synopsis forms and a reply or new message is composed using the reply, Reply, followup, Followup, or mail commands and standard input is a terminal. When the message is typed and the end of the message is encountered, the message shall be passed to the mail delivery software. Commands can be entered by beginning a line with the escape character (by default, <tilde> ('~')) followed by a single command letter and optional arguments. See Commands in mailx for a summary of these commands. It is unspecified what effect these commands will have if standard input is not a terminal when a message is entered using either the Send Mode synopsis, or the Read Mode commands reply, Reply, followup, Followup, or mail. That part is giving "undefined behavior, proceed with caution" vibes, ngl. ๐Ÿซ 

Note: For notational convenience, this section uses the default escape character, <tilde>, in all references and examples. ๐ŸŽ€ iykyk.

At any time, the behavior of mailx shall be governed by a set of environmental and internal variables. These are flags and valued parameters that can be set and cleared via the mailx set and unset commands. Obsessed with the flexibility, honestly. โœจ

Regular commands are of the form:

[command] [msglist] [argument ...]

If no command is specified in command mode, next shall be assumed. In input mode, commands shall be recognized by the escape character, and lines not treated as commands shall be taken as input for the message. Lowkey elegant.

In command mode, each message shall be assigned a sequential number, starting with 1. Simple. Iconic.

All messages have a state that shall affect how they are displayed in the header summary and how they are retained or deleted upon termination of mailx. There is at any time the notion of a current message, which shall be marked by a > at the beginning of a line in the header summary. When mailx is invoked using one of the Receive Mode synopsis forms, the current message shall be the first new message, if there is a new message, or the first unread message if there is an unread message, or the first message if there are any messages, or unspecified if there are no messages in the mailbox. Each command that takes an optional list of messages (msglist) or an optional single message (message) on which to operate shall leave the current message set to the highest-numbered message of the messages specified, unless the command deletes messages, in which case the current message shall be set to the first undeleted message (that is, a message not in the deleted state) after the highest-numbered message deleted by the command, if one exists, or the first undeleted message before the highest-numbered message deleted by the command, if one exists, or to an unspecified value if there are no remaining undeleted messages. All messages shall be in one of the following states:

  • new โ€” The message is present in the system mailbox and has not been viewed by the user or moved to any other state. Messages in state new when mailx quits shall be retained in the system mailbox.
  • unread โ€” The message has been present in the system mailbox for more than one invocation of mailx and has not been viewed by the user or moved to any other state. Messages in state unread when mailx quits shall be retained in the 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 delete, dp, and dt commands may also cause the next message to be marked as read, depending on the value of the autoprint variable. Messages that are in the system mailbox and in state read when mailx quits shall be saved in the mbox, unless the internal variable hold was set. Messages that are in the mbox or in a secondary mailbox and in state read when mailx quits shall be retained in their current location.
  • deleted โ€” The message has been processed by one of the following commands: delete, dp, dt. Messages in state deleted when mailx quits shall be deleted. Deleted messages shall be ignored until mailx quits or changes mailboxes or they are specified to the undelete command; for example, the message specification /string shall only search the subject lines of messages that have not yet been deleted, unless the command operating on the list of messages is undelete. No deleted message or deleted message header shall be displayed by any mailx command other than undelete. ๐Ÿ’€
  • preserved โ€” The message has been processed by a preserve command. When mailx quits, the message shall be retained in its current location.
  • saved โ€” The message has been processed by one of the following commands: save or write. If the current mailbox is the system mailbox, and the internal variable keepsave is set, messages in the state saved shall be saved to the file designated by the MBOX variable (see the ENVIRONMENT VARIABLES section). If the current mailbox is the system mailbox, messages in the state saved shall be deleted from the current mailbox, when the quit or file command is used to exit the current mailbox.

The header-summary line for each message shall indicate the state of the message. It's giving โœจorganized chaosโœจ, and we love that for us.

Many commands take an optional list of messages (msglist) on which to operate, which defaults to the current message. A msglist is a list of message specifications separated by <blank> characters, which can include:

  • n โ€” Message number n.
  • + โ€” The next undeleted message, or the next deleted message for the undelete command.
  • - โ€” The next previous undeleted message, or the next previous deleted message for the undelete command.
  • . โ€” The current message.
  • ^ โ€” The first undeleted message, or the first deleted message for the undelete command.
  • $ โ€” The last message.
  • * โ€” All messages.
  • nโ€m โ€” An inclusive range of message numbers.
  • address โ€” All messages from address; any address as shown in a header summary shall be matchable in this form.
  • /string โ€” All messages with string in the subject line (case ignored).
  • :c โ€” All messages of type c, where c shall be one of:
    • d โ€” Deleted messages.
    • n โ€” New messages.
    • o โ€” Old messages (any not in state read or new).
    • r โ€” Read messages.
    • u โ€” Unread messages.

Other commands take an optional message (message) on which to operate, which defaults to the current message. All of the forms allowed for msglist are also allowed for message, but if more than one message is specified, only the first shall be operated on. The way that works is lowkey satisfying, ngl.

Other arguments are usually arbitrary strings whose usage depends on the command involved. Bestie, you just gotta read the room on those.


๐Ÿ’ซ Start-Up in mailx ๐Ÿ’ซ

At start-up time, mailx shall take the following steps in sequence:

  1. Establish all variables at their stated default values.
  2. Process command line options, overriding corresponding default values.
  3. Import any of the DEAD, EDITOR, MBOX, LISTER, PAGER, SHELL, or VISUAL variables that are present in the environment, overriding the corresponding default values.
  4. Read mailx commands from an unspecified system start-up file, unless the -n option is given, to initialize any internal mailx variables and aliases.
  5. Process the user start-up file of mailx commands named in the user MAILRC variable.

Most regular mailx commands are valid inside start-up files, the most common use being to set up initial display options and alias lists. The following commands shall be invalid in a start-up file: !, edit, hold, mail, preserve, reply, Reply, shell, visual, Copy, followup, and Followup. Any errors in a start-up file shall either cause mailx to terminate with a diagnostic message and a non-zero status or to continue after writing a diagnostic message, ignoring the remainder of the lines in the file. Not me reading that and feeling personally attacked by the strictness. ๐Ÿ™ˆ

A blank line in a start-up file shall be ignored. Peace and quiet, finally.


๐ŸŒธ Internal Variables in mailx ๐ŸŒธ

The following variables are internal mailx variables. Each internal variable can be set via the mailx set command at any time. The unset and set no name commands can be used to erase variables. Very demure, very mindful.

In the following list, variables shown as:

variable

represent Boolean values. Variables shown as:

variable=value

shall be assigned string or numeric values. For string values, the rules in Commands in mailx concerning filenames and quoting shall also apply.

The defaults specified here may be changed by the unspecified system start-up file unless the user specifies the -n option.

  • allnet โ€” All network names whose login name components match shall be treated as identical. This shall cause the msglist message specifications to behave similarly. The default shall be noallnet. See also the alternates command and the metoo variable.
  • append โ€” Append messages to the end of the mbox file upon termination instead of placing them at the beginning. The default shall be noappend. This variable shall not affect the save command when saving to mbox.
  • ask, asksub โ€” Prompt for a subject line on outgoing mail if one is not specified on the command line with the -s option. The ask and asksub forms are synonyms; the system shall refer to asksub and noasksub in its messages, but shall accept ask and noask as user input to mean asksub and noasksub. It shall not be possible to set both ask and noasksub, or noask and asksub. The default shall be asksub, but no prompting shall be done if standard input is not a terminal.
  • askbcc โ€” Prompt for the blind copy list. The default shall be noaskbcc.
  • askcc โ€” Prompt for the copy list. The default shall be noaskcc.
  • autoprint โ€” switch this on and mailx auto-writes the message for you right after a delete or undelete command, no extra keystrokes needed. default: noautoprint. ๐Ÿ’…
  • bang โ€” turns on the special-case treatment of <exclamation-mark> characters ('!') inside escape command lines; peep the escape command and Command Escapes in mailx for the full tea. default: nobang, which means no expansion of '!' in the command argument to the ~! command and the ~<!command escape. ๐Ÿ˜Œ
  • cmd=command โ€” sets the default command that the pipe command invokes. default: nocmd.
  • crt=number โ€” any message with more than number lines gets piped through whatever command the PAGER variable holds. default: nocrt. if you set it to null, the value used is implementation-defined. ๐Ÿคท
  • debug โ€” verbose diagnostics for debugging, bestie. heads up: messages are not delivered in this mode. default: nodebug.
  • dot โ€” when dot is set, a <period> sitting on a line all by itself during message input from a terminal also means end-of-file (on top of the normal end-of-file). default: nodot. but if ignoreeof is set (scroll down), a setting of nodot gets ignored and the <period> becomes the only way to terminate input mode. ๐Ÿ‘‘
  • escape=c โ€” sets the command escape character to the character 'c'. by default the command escape character is <tilde>. if escape is unset, <tilde> gets used; if it's set to null, command escaping is disabled entirely.
  • flipr โ€” swaps the meanings of the R and r commands. default: noflipr.
  • folder=directory โ€” the default directory for saving mail files. user-specified filenames starting with a <plus-sign> ('+') get expanded by sticking this directory name in front of the filename to build the real pathname. if directory doesn't start with a <slash> ('/'), the contents of HOME get prefixed onto it. default: nofolder. if folder is unset or set to null, user-specified filenames starting with '+' refer to files in the current directory whose names begin with a literal '+' character. see also outfolder below. also note: the folder value doesn't have to affect how the files named in MBOX and DEAD get processed. ๐Ÿ’–
  • header โ€” enables writing the header summary when you enter mailx in Receive Mode. default: header.
  • hold โ€” preserves every message read in the system mailbox instead of shipping them off to the mbox save file. default: nohold.
  • ignore โ€” ignores interrupts while you're entering messages. default: noignore.
  • ignoreeof โ€” ignores normal end-of-file during message input. input can then only be terminated by entering a <period> ('.') on a line by itself, or by the ~. command escape. default: noignoreeof. see also dot above. ๐Ÿซถ
  • indentprefix=string โ€” a string that gets added as a prefix to every line the ~m command escape inserts into the message. this variable defaults to one <tab>.
  • keep โ€” when a system mailbox, secondary mailbox, or mbox is empty, truncate it to zero length instead of removing it. default: nokeep.
  • keepsave โ€” keeps the messages that were saved from the system mailbox into other files, storing them in the file designated by the MBOX variable instead of deleting them. default: nokeepsave.
  • metoo โ€” suppresses the deletion of the user's login name from the recipient list when replying to a message or sending to a group. default: nometoo.
  • onehop โ€” when you respond to a message that was originally sent to several recipients, the other recipient addresses are normally forced to be relative to the originating author's machine for the response. this flag disables that alteration of the recipients' addresses, which makes things more efficient in a network where all machines can send directly to all other machines (i.e. they're one hop away). default: noonehop.
  • outfolder โ€” makes the files used to record outgoing messages live in the directory specified by the folder variable, unless the pathname is absolute. default: nooutfolder. see the record variable. โœจ
  • page โ€” inserts a <form-feed> after each message sent through the pipe created by the pipe command. default: nopage.
  • prompt=string โ€” sets the command-mode prompt to string. if string is null, or if noprompt is set, no prompting happens at all. the default is to prompt with the string "? ".
  • quiet โ€” refrains from writing the opening message and version when entering mailx. default: noquiet.
  • record=file โ€” records all outgoing mail in the file with the pathname file. default: norecord. see also outfolder above.
  • save โ€” enables saving of messages in the dead-letter file on interrupt or delivery error. check the DEAD variable for where that dead-letter file lives. default: save.
  • screen=number โ€” sets the number of lines in a screenful of headers for the headers and z commands. if screen isn't specified, a value based on the terminal type identified by the TERM environment variable, the window size, the baud rate, or some combo of those gets used. ๐ŸŒธ
  • sendwait โ€” waits for the background mailer to finish before returning. default: nosendwait.
  • showto โ€” when the sender of the message was the user who's invoking mailx, write the info from the To: line instead of the From: line in the header summary. default: noshowto.
  • sign=string โ€” sets the variable that gets inserted into the text of a message when the ~a command escape is given. default: nosign. the character sequences '\t' and '\n' are recognized inside the variable as <tab> and <newline> characters respectively. (see also ~i in Command Escapes in mailx.) ๐Ÿ’œ
  • Sign=string โ€” sets the variable that gets inserted into the text of a message when the ~A command escape is given. default: noSign. the character sequences '\t' and '\n' are recognized inside the variable as <tab> and <newline> characters respectively.
  • toplines=number โ€” sets how many lines of the message the top command writes out. default: 5.

Commands in mailx ๐ŸŽ€

okay bestie, here's the whole command roster. in the list below, header means lines from the message header, exactly like what's shown in the OUTPUT FILES section. Header-line means lines within the header that begin with one or more non-white-space characters, immediately followed by a <colon> and white space, and continuing until the next line that starts with a non-white-space character or an empty line. Header-field means the portion of a header line before the first <colon> in that line. ๐Ÿ“ฌ

for each command listed below, you can type it as the abbreviation (those characters in the Synopsis command word that come before the '['), the full command (every character shown for the command word, minus the '[' and ']'), or any truncation of the full command down to the abbreviation. for example, the exit command (shown as ex[it] in the Synopsis) can be entered as ex, exi, or exit. slay, flexible. ๐Ÿ’…

the arguments to commands can be quoted, using these methods:

  • an argument can be wrapped in paired double-quotes ("") or single-quotes (''); any white space, shell word expansion, or <backslash> characters inside those quotes are treated literally as part of the argument. a double-quote is treated literally inside single-quotes and vice versa. these special properties of the <quotation-mark> characters only kick in when they're paired at the beginning and end of the argument. ๐Ÿ”ฅ
  • a <backslash> outside of the enclosing quotes gets discarded, and the character right after it is treated literally as part of the argument.
  • an unquoted <backslash> at the end of a command line gets discarded, and the next line continues the command. (line-continuation vibes.)

filenames, where a command expects one, go through these transformations, in sequence:

  • if the filename begins with an unquoted <plus-sign>, and the folder variable is defined (see the folder variable), the <plus-sign> gets replaced by the value of the folder variable followed by a <slash>. if the folder variable is unset or set to null, the filename stays unchanged.
  • shell word expansions get applied to the filename (see Section 2.6, Word Expansions). if more than a single pathname results from that expansion and the command is only expecting one file, the effects are unspecified. ๐Ÿ™ˆ

Declare Aliases ๐Ÿฆ‹

Synopsis:

a[lias] [alias [address...]]
g[roup] [alias [address...]]

adds the given addresses to the alias specified by alias. the names get substituted when alias is used as a recipient address specified by the user in an outgoing message โ€” meaning other recipients addressed indirectly through the reply command do not get substituted this way. mail address alias substitution applies only when the alias string is used as a full address; for example, when hlj is an alias, hlj@posix.com does not trigger the alias substitution. iykyk. ๐Ÿ˜ญ

if no arguments are given, write a listing of the current aliases to standard output. if only an alias argument is given, write a listing of that specified alias to standard output. heads up: these listings don't have to reflect the same order of addresses that were entered. ๐Ÿ™ƒ


Declare Alternatives ๐ŸŒˆ

Synopsis:

alt[ernates] name...

(see also the metoo variable.) declares a list of alternative names for the user's login. when responding to a message, these names get removed from the list of recipients for the response. the comparison of names is case-insensitive. with no arguments, alternates writes the current list of alternative names. ๐Ÿ’–


Change Current Directory ๐Ÿงš

Synopsis:

cd [directory]
ch[dir] [directory]

changes directory. if directory isn't specified, the contents of HOME get used. ๐Ÿ 


Copy Messages โญ

Synopsis:

c[opy] [file]
c[opy] [msglist] file
C[opy] [msglist]

okay so bestie, c[opy] is literally the save command's twin but it does not mark messages as saved. Copy messages to the file named by the pathname file without marking the messages as saved. Otherwise, it shall be equivalent to the save command. โœจ

And the capitalized C[opy]? It saves the specified messages in a file whose name is derived from the author of the message to be saved, again without marking them as saved. Otherwise, it shall be equivalent to the Save command. ๐Ÿ’…


๐Ÿ—‘๏ธ Delete Messages ๐Ÿ—‘๏ธ

d[elete] [msglist]

Mark messages for deletion from the mailbox. The deletions shall not occur until mailx quits (see the quit command) or changes mailboxes (see the folder command). If autoprint is set and there are messages remaining after the delete command, the current message shall be written as described for the print command (see the print command); otherwise, the mailx prompt shall be written. ๐Ÿ˜ญ


๐Ÿ™ˆ Discard Header Fields ๐Ÿ™ˆ

di[scard] [header-field...]
ig[nore] [header-field...]

Suppress the specified header fields when writing messages. Specified header-fields shall be added to the list of suppressed header fields. Examples of header fields to ignore are status and cc. The fields shall be included when the message is saved. The Print and Type commands shall override this command. The comparison of header fields shall be in a case-insensitive manner. If no arguments are specified, write a list of the currently suppressed header fields to standard output; the listing need not reflect the same order of header fields that were entered. ๐Ÿ‘‘

If both retain and discard commands are given, discard commands shall be ignored. ๐Ÿ’€

๐Ÿ—‘๏ธ Delete Messages and Display ๐Ÿ—‘๏ธ

dp [msglist]
dt [msglist]

Delete the specified messages as described for the delete command, except that the autoprint variable shall have no effect, and the current message shall be written only if it was set to a message after the last message deleted by the command. Otherwise, an informational message to the effect that there are no further messages in the mailbox shall be written, followed by the mailx prompt. ๐ŸŒธ


๐Ÿ—ฃ๏ธ Echo a String ๐Ÿ—ฃ๏ธ

ec[ho] string ...

Echo the given strings, equivalent to the shell echo utility. ๐Ÿฆ‹


โœ๏ธ Edit Messages โœ๏ธ

e[dit] [msglist]

Edit the given messages. The messages shall be placed in a temporary file and the utility named by the EDITOR variable is invoked to edit each file in sequence. The default EDITOR is unspecified. ๐Ÿ’œ

The edit command does not modify the contents of those messages in the mailbox. ๐Ÿ™…โ€โ™€๏ธ


๐Ÿšช Exit ๐Ÿšช

ex[it]
x[it]

Exit from mailx without changing the mailbox. No messages shall be saved in the mbox (see also quit). ๐Ÿ‘‹


๐Ÿ“ Change Folder ๐Ÿ“

fi[le] [file]
fold[er] [file]

Quit (see the quit command) from the current file of messages and read in the file named by the pathname file. If no argument is given, the name and status of the current mailbox shall be written. ๐Ÿ—‚๏ธ

Several unquoted special characters shall be recognized when used as file names, with the following substitutions:

  • % โ€” The system mailbox for the invoking user.
  • %user โ€” The system mailbox for user.
  • # โ€” The previous file.
  • & โ€” The current mbox.
  • +file โ€” The named file in the folder directory. (See the folder variable.)

The default file shall be the current mailbox. ๐Ÿ’–


๐Ÿ“‚ Display List of Folders ๐Ÿ“‚

folders

Write the names of the files in the directory set by the folder variable. The command specified by the LISTER environment variable shall be used (see the ENVIRONMENT VARIABLES section). โœจ


๐Ÿ“ฌ Follow Up Specified Messages ๐Ÿ“ฌ

fo[llowup] [message]
F[ollowup] [msglist]

In the lowercase form, respond to a message, recording the response in a file whose name is derived from the author of the message. See also the save and copy commands and outfolder. ๐ŸŒˆ

In the capitalized form, respond to the first message in the msglist, sending the message to the author of each message in the msglist. The subject line shall be taken from the first message and the response shall be recorded in a file whose name is derived from the author of the first message. See also the Save and Copy commands and outfolder. ๐Ÿ”ฅ

Both forms shall override the record variable, if set. ๐Ÿ’…


๐Ÿ“‹ Display Header Summary for Specified Messages ๐Ÿ“‹

f[rom] [msglist]

Write the header summary for the specified messages. ๐ŸŽ€


๐Ÿ“œ Display Header Summary ๐Ÿ“œ

h[eaders] [message]

Write the page of headers that includes the message specified. If the message argument is not specified, the current message shall not change. However, if the message argument is specified, the current message shall become the message that appears at the top of the page of headers that includes the message specified. The screen variable sets the number of headers per page. See also the z command. ๐Ÿ’ซ


๐Ÿ†˜ Help ๐Ÿ†˜

hel[p]
?

Write a summary of commands. ๐Ÿ™‹โ€โ™€๏ธ


โœ‹ Hold Messages โœ‹

ho[ld] [msglist]
pre[serve] [msglist]

Mark the messages in msglist to be retained in the mailbox when mailx terminates. This shall override any commands that might previously have marked the messages to be deleted. During the current invocation of mailx, only the delete, dp, or dt commands shall remove the preserve marking of a message. ๐Ÿ”’


๐Ÿค” Execute Commands Conditionally ๐Ÿค”

i[f] s|r
mail-commands
el[se]
mail-commands
en[dif]

Execute commands conditionally, where if s executes the following mail-commands, up to an else or endif, if the program is in Send Mode, and if r shall cause the mail-commands to be executed only in Receive Mode. ๐Ÿงš


๐Ÿ“ List Available Commands ๐Ÿ“

l[ist]

Write a list of all commands available. No explanation shall be given. ๐Ÿค


๐Ÿ“ง Mail a Message ๐Ÿ“ง

m[ail] address...

Mail a message to the specified addresses or aliases. ๐Ÿ’Œ


๐Ÿ“ฅ Direct Messages to mbox ๐Ÿ“ฅ

mb[ox] [msglist]

Arrange for the given messages to end up in the mbox save file when mailx terminates normally. See MBOX. See also the exit and quit commands. ๐Ÿ—ƒ๏ธ


โญ๏ธ Process Next Specified Message โญ๏ธ

n[ext] [message]

If the current message has not been written (for example, by the print command) since mailx started or since any other message was the current message, behave as if the print command was entered. Otherwise, if there is an undeleted message after the current message, make it the current message and behave as if the print command was entered. Otherwise, an informational message to the effect that there are no further messages in the mailbox shall be written, followed by the mailx prompt. Should the current message location be the result of an immediately preceding hold, mbox, preserve, or touch command, next will act as if the current message has already been written. ๐Ÿ˜ฎโ€๐Ÿ’จ


๐Ÿšฐ Pipe Message ๐Ÿšฐ

pi[pe] [[msglist] command]
| [[msglist] command]

Pipe the messages through the given command by invoking the command interpreter specified by SHELL with two arguments: -c and command. (See also sh -c.) The application shall ensure that the command is given as a single argument. Quoting, described previously, can be used to accomplish this. If no arguments are given, the current message shall be piped through the command specified by the value of the cmd variable. If the page variable is set, a <form-feed> shall be inserted after each message. ๐Ÿ’ง


๐Ÿ“„ Display Message with Headers ๐Ÿ“„

P[rint] [msglist]
T[ype] [msglist]

Write the specified messages, including all header lines, to standard output. Override suppression of lines by the discard, ignore, and retain commands. If crt is set, the messages longer than the number of lines specified by the crt variable shall be paged through the command specified by the PAGER environment variable. ๐Ÿ“–


๐Ÿ“ƒ Display Message ๐Ÿ“ƒ

p[rint] [msglist]
t[ype] [msglist]

Write the specified messages to standard output. If crt is set, the messages longer than the number of lines specified by the crt variable shall be paged through the command specified by the PAGER environment variable. ๐Ÿ“„


๐Ÿšช Quit ๐Ÿšช

q[uit]
end-of-file

Terminate mailx, storing messages that were read in mbox (if the current mailbox is the system mailbox and unless hold is set), deleting messages that have been explicitly saved (unless keepsave is set), discarding messages that have been deleted, and saving all remaining messages in the mailbox. ๐Ÿ


โ†ฉ๏ธ Reply to a Message List โ†ฉ๏ธ

R[eply] [msglist]
R[espond] [msglist]

Mail a reply message to the sender of each message in the msglist. The subject line shall be formed by concatenating Re:<space> (unless it already begins with that string) and the subject from the first message. If record is set to a filename, the response shall be saved at the end of that file. ๐Ÿ’ฌ

See also the flipr variable. ๐Ÿ”„


โ†ฉ๏ธ Reply to a Message โ†ฉ๏ธ

r[eply] [message]
r[espond] [message]

Mail a reply message to all recipients included in the header of the message. The subject line shall be formed by concatenating Re:<space> (unless it already begins with that string) and the subject from the message. If record is set to a filename, the response shall be saved at the end of that file. ๐Ÿ’ฌ

See also the flipr variable. ๐Ÿ”„


๐Ÿ“Œ Retain Header Fields ๐Ÿ“Œ

ret[ain] [header-field...]

Retain the specified header fields when writing messages. This command shall override all discard and ignore commands. The comparison of header fields shall be in a case-insensitive manner. If no arguments are specified, write a list of the currently retained header fields to standard output; the listing need not reflect the same order of header fields that were entered. ๐Ÿ’–


๐Ÿ’พ Save Messages ๐Ÿ’พ

s[ave] [file]
s[ave] [msglist] file
S[ave] [msglist]

Save the specified messages in the file named by the pathname file, or in the mbox if the file argument is omitted. ๐Ÿ’พ The file shall be created if it does not exist; otherwise, the messages shall be appended to the file. The message shall be put in the state saved, and shall behave as specified in the description of the saved state when the current mailbox is exited by the quit or file command.

In the capitalized form, save the specified messages in a file whose name is derived from the author of the first message. The name of the file shall be taken to be the author's name with all network addressing stripped off. ๐Ÿ‘‘ See also the Copy, followup, and Followup commands and the outfolder variable.


๐ŸŽ€ Set Variables ๐ŸŽ€

Synopsis:

se[t] [name[=[string]] ...] [name=number ...] [noname ...]

Define one or more variables called name. โœจ The variable can be given a null, string, or numeric value. Quoting and <backslash>-escapes can occur anywhere in string, as described previously, as if the string portion of the argument were the entire argument. The forms name and name= shall be equivalent to name="" for variables that take string values. The set command without arguments shall write a list of all defined variables and their values. The no name form shall be equivalent to unset name.

๐Ÿš Invoke a Shell ๐Ÿš

Synopsis:

sh[ell]

Invoke an interactive command interpreter (see also SHELL). ๐Ÿ’…

๐Ÿ“ Display Message Size ๐Ÿ“

Synopsis:

si[ze] [msglist]

Write the size in bytes of each of the specified messages.

๐Ÿ“‚ Read mailx Commands From a File ๐Ÿ“‚

Synopsis:

so[urce] file

Read and execute commands from the file named by the pathname file and return to command mode. ๐Ÿฆ‹

๐Ÿ” Display Beginning of Messages ๐Ÿ”

Synopsis:

to[p] [msglist]

Write the top few lines of each of the specified messages. If the toplines variable is set, it is taken as the number of lines to write. The default shall be 5.

๐Ÿ‘† Touch Messages ๐Ÿ‘†

Synopsis:

tou[ch] [msglist]

Touch the specified messages. If any message in msglist is not specifically deleted nor saved in a file, it shall be placed in the mbox upon normal termination. See exit and quit.

๐Ÿ—‘๏ธ Delete Aliases ๐Ÿ—‘๏ธ

Synopsis:

una[lias] [alias]...

Delete the specified alias names. If a specified alias does not exist, the results are unspecified. ๐Ÿ˜ฌ

โ†ฉ๏ธ Undelete Messages โ†ฉ๏ธ

Synopsis:

u[ndelete] [msglist]

Change the state of the specified messages from deleted to read. If autoprint is set, the last message of those restored shall be written. If msglist is not specified, the message shall be selected as follows:

  • If there are any deleted messages that follow the current message, the first of these shall be chosen.
  • Otherwise, the last deleted message that also precedes the current message shall be chosen.

๐Ÿงน Unset Variables ๐Ÿงน

Synopsis:

uns[et] name...

Cause the specified variables to be erased. poof ๐Ÿ’จ

๐Ÿ–ฅ๏ธ Edit Message with Full-Screen Editor ๐Ÿ–ฅ๏ธ

Synopsis:

v[isual] [msglist]

Edit the given messages with a screen editor. Each message shall be placed in a temporary file, and the utility named by the VISUAL variable shall be invoked to edit each file in sequence. The default editor shall be vi.

The visual command does not modify the contents of those messages in the mailbox. no cap ๐Ÿซถ

โœ๏ธ Write Messages to a File โœ๏ธ

Synopsis:

w[rite] [msglist] file

Write the given messages to the file specified by the pathname file, minus the message header. Otherwise, it shall be equivalent to the save command.

๐Ÿ“œ Scroll Header Display ๐Ÿ“œ

Synopsis:

z[+|-]

Scroll the header display forward (if '+' is specified or if no option is specified) or backward (if '-' is specified) one screenful. The number of headers written shall be set by the screen variable.

๐Ÿ’ฅ Invoke Shell Command ๐Ÿ’ฅ

Synopsis:

!command

Invoke the command interpreter specified by SHELL with two arguments: -c and command. (See also sh -c.) If the bang variable is set, each unescaped occurrence of '!' in command shall be replaced with the command executed by the previous ! command or ~! command escape.

๐Ÿšซ Null Command ๐Ÿšซ

Synopsis:

# comment

This null command (comment) shall be ignored by mailx. literally invisible โœจ

๐Ÿ”ข Display Current Message Number ๐Ÿ”ข

Synopsis:

=

Write the current message number.


๐Ÿ’Œ Command Escapes in mailx ๐Ÿ’Œ

The following commands can be entered only from input mode, by beginning a line with the escape character (by default, <tilde> ('~')). See the escape variable description for changing this special character. The format for the commands shall be:

<escape-character><command-char><separator>[<arguments>]

where the <separator> can be zero or more <blank> characters.

In the following descriptions, the application shall ensure that the argument command (but not mailx-command) is a shell command string. Any string acceptable to the command interpreter specified by the SHELL variable when it is invoked as SHELL -c command_string shall be valid. The command can be presented as multiple arguments (that is, quoting is not required). ๐Ÿš

Command escapes that are listed with msglist or mailx-command arguments are invalid in Send Mode and produce unspecified results. bestie pls don't ๐Ÿ˜ญ
  • ~! command โ€” Invoke the command interpreter specified by SHELL with two arguments: -c and command; and then return to input mode. If the bang variable is set, each unescaped occurrence of '!' in command shall be replaced with the command executed by the previous ! command or ~! command escape.
  • ~. โ€” Simulate end-of-file (terminate message input).
  • ~: mailx-command, ~_ mailx-command โ€” Perform the command-level request.
  • ~? โ€” Write a summary of command escapes. ๐Ÿซถ
  • ~A โ€” This shall be equivalent to ~i Sign.
  • ~a โ€” This shall be equivalent to ~i sign.
  • ~b name... โ€” Add the names to the blind carbon copy (Bcc) list.
  • ~c name... โ€” Add the names to the carbon copy (Cc) list.
  • ~d โ€” Read in the dead-letter file. See DEAD for a description of this file. ๐Ÿ’€
  • ~e โ€” Invoke the editor, as specified by the EDITOR environment variable, on the partial message.
  • ~f [msglist] โ€” Forward the specified messages. The specified messages shall be inserted into the current message without alteration. This command escape also shall insert message headers into the message with field selection affected by the discard, ignore, and retain commands.
  • ~F [msglist] โ€” This shall be the equivalent of the ~f command escape, except that all headers shall be included in the message, regardless of previous discard, ignore, and retain commands.
  • ~h โ€” If standard input is a terminal, prompt for a Subject line and the To, Cc, and Bcc lists. Other implementation-defined headers may also be presented for editing. If the field is written with an initial value, it can be edited as if it had just been typed.
  • ~i string โ€” Insert the value of the named variable, followed by a <newline>, into the text of the message. If the string is unset or null, the message shall not be changed.
  • ~m [msglist] โ€” Insert the specified messages into the message, prefixing non-empty lines with the string in the indentprefix variable. This command escape also shall insert message headers into the message, with field selection affected by the discard, ignore, and retain commands.
  • ~M [msglist] โ€” This shall be the equivalent of the ~m command escape, except that all headers shall be included in the message, regardless of previous discard, ignore, and retain commands.
  • ~p โ€” Write the message being entered. If the message is longer than crt lines (see Internal Variables in mailx), the output shall be paginated as described for the PAGER variable.
  • ~q โ€” Quit (see the quit command) from input mode by simulating an interrupt. If the body of the message is not empty, the partial message shall be saved in the dead-letter file. See DEAD for a description of this file. ๐Ÿ’€
  • ~r file, ~< file, ~r !command, ~< !command โ€” Read in the file specified by the pathname file. If the argument begins with an <exclamation-mark> ('!'), the rest of the string shall be taken as an arbitrary system command; the command interpreter specified by SHELL shall be invoked with two arguments: -c and command. The standard output of command shall be inserted into the message.
  • ~s string โ€” Set the subject line to string.
  • ~t name... โ€” Add the given names to the To list.
  • ~v โ€” Invoke the full-screen editor, as specified by the VISUAL environment variable, on the partial message.
  • ~w file โ€” Write the partial message, without the header, onto the file named by the pathname file. The file shall be created or the message shall be appended to it if the file exists.
  • ~x โ€” Exit as with ~q, except the message shall not be saved in the dead-letter file.
  • ~| command โ€” Pipe the body of the message through the given command by invoking the command interpreter specified by SHELL with two arguments: -c and command. If the command returns a successful exit status, the standard output of the command shall replace the message. Otherwise, the message shall remain unchanged. If the command fails, an error message giving the exit status shall be written. ๐Ÿ˜ค

โœจ EXIT STATUS โœจ

When the -e option is specified, the following exit values are returned:

  • 0 โ€” Mail was found. ๐ŸŽ‰
  • >0 โ€” Mail was not found or an error occurred. ๐Ÿ˜ญ

Otherwise, the following exit values are returned:

  • 0 โ€” Successful completion; note that this status implies that all messages were sent, but it gives no assurances that any of them were actually delivered. ๐Ÿ‘€
  • >0 โ€” An error occurred. ๐Ÿ’€

๐Ÿ’€ CONSEQUENCES OF ERRORS ๐Ÿ’€

ok bestie so like, what actually happens when stuff goes wrong? depends on the mode, and it's giving very different energy depending on where you are:

when you're in input mode (aka Receive Mode) or Send Mode ๐Ÿซถ

  • So if there's an error while it's processing an input line that starts with a <tilde> ('~') character โ€” yk, the whole Command Escapes in mailx situation โ€” then a diagnostic message gets written to standard error, and the message you're composing may get modified, but lowkey this condition does not stop the message from being sent. slay, it still goes.
  • Any other errors? yeah no, those shall prevent the sending of the message. periodt. โœ‹

when you're in command mode ๐Ÿ‘‘

  • Default.

The following sections are informative.

๐ŸŒˆ APPLICATION USAGE ๐ŸŒˆ

So, getting messages to remote systems? That requires communication paths to those systems to actually exist. And likeโ€ฆ they might not. Not our problem though ๐Ÿ’….

Input lines are capped at {LINE_MAX} bytes, but bestie, mailers sitting between systems may impose way harsher line-length restrictions. This volume of POSIX.1โ€2017 does not place any restrictions on the length of messages handled by mailx, and for delivering local messages the only limitations should really just be the normal problems of available disk space for the target mail file. But when you're sending to external machines, applications are advised to keep messages under 100000 bytes, because some mail gateways impose message-length restrictions. Not me finding that out the hard way ๐Ÿ™ˆ.

The format of the system mailbox is intentionally unspecified. Not all systems implement system mailboxes as flat files โ€” especially with multimedia mail messages entering the chat. Some system mailboxes may be multiple files, others records in a database. The internal format of the messages themselves is specified with the historical format from Version 7, but only after the messages have been saved in some file other than the system mailbox. Why? So that all those historical applications expecting text-file mailboxes don't get broken. iconic behaviour honestly.

And bestie, some new formats for messages can be expected in the future โ€” probably including binary data, bit maps, and various multimedia objects. The way this is written, mailx isn't prohibited from handling such messages, but it must store them as text files in secondary mailboxes (unless some extension, like a variable or command line option, is used to change the stored format). Its method of doing so is implementation-defined and might include translating the data into text file-compatible or readable form, or omitting certain portions of the message from the stored output. iykyk ๐ŸŒธ.

ok important lore: the discard and ignore commands are not inverses of the retain command. let that sink in:

  • retain discards all header-fields except those explicitly retained.
  • discard keeps all header-fields except those explicitly discarded.
  • And if headers exist on the retained header list, discard and ignore commands are ignored. periodt.

โœจ EXAMPLES โœจ

None. ๐Ÿ˜ญ (yeah, fr fr, there are literally none. we move.)

๐Ÿงš RATIONALE ๐Ÿงš

The standard developers felt strongly that applications needed a way to send messages to specific users. The obvious example? A batch utility, running non-interactively, that wants to communicate errors or results to a user. But the actual format, delivery mechanism, and method of reading the message are clearly beyond the scope of this volume of POSIX.1โ€2017. not their business, not their problem ๐Ÿ’….

The intent of this command is to provide a simple, portable interface for sending messages non-interactively. It merely defines a ``front-end'' to the historical mail system. It is suggested that implementations explicitly denote the sender and recipient in the body of the delivered message. Further specification of formats for either the message envelope or the message itself were deliberately not made, as the industry is in the midst of changing from the current standards to a more internationalized standard and it is probably incorrect, at this time, to require either one. it's giving "we're mid-transition, don't @ us".

Implementations are encouraged to conform to the various delivery mechanisms described in the CCITT X.400 standards or to the equivalent Internet standards, described in Internet Request for Comment (RFC) documents RFC 819, RFC 920, RFC 921, RFC 1123, and RFC 5322 (which succeeded RFC 822). ๐ŸŒ

Many historical systems modified each body line that started with From by prefixing the 'F' with '>'. It is unnecessary, but allowed, to do that when the string does not follow a blank line because it cannot be confused with the next header. so likeโ€ฆ optional, but valid โœจ.

The edit and visual commands merely edit the specified messages in a temporary file. They do not modify the contents of those messages in the mailbox; such a capability could be added as an extension, such as by using different command names. no sneaky edits bestie, it's temporary only ๐ŸŽ€.

The restriction on a subject line being {LINE_MAX}-10 bytes is based on the historical format that consumes 10 bytes for Subject: and the trailing <newline>. Many historical mailers that a message may encounter on other systems are not able to handle lines that long, however. ๐Ÿ’€

Like the utilities logger and lp, mailx admittedly is difficult to test. This was not deemed sufficient justification to exclude this utility from this volume of POSIX.1โ€2017. It is also arguable that it is, in fact, testable, but that the tests themselves are not portable. okay so it's giving "hard to test but we're not dropping it".

When mailx is being used by an application that wishes to receive the results as if none of the User Portability Utilities option features were supported, the DEAD environment variable must be set to /dev/null. Otherwise, it may be subject to the file creations described in mailx ASYNCHRONOUS EVENTS. Similarly, if the MAILRC environment variable is not set to /dev/null, historical versions of mailx and Mail read initialization commands from a file before processing begins. Since the initialization that a user specifies could alter the contents of messages an application is trying to send, such applications must set MAILRC to /dev/null. > this is a big deal bestie โ€” set those to /dev/null or your app's messages could get messed with.

The description of LC_TIME uses ``may affect'' because many historical implementations do not or cannot manipulate the date and time strings in the incoming mail headers. Some headers found in incoming mail do not have enough information to determine the timezone in which the mail originated, and, therefore, mailx cannot convert the date and time strings into the internal form that then is parsed by routines like strftime() that can take LC_TIME settings into account. Changing all these times to a user-specified format is allowed, but not required. ๐Ÿ•ฐ๏ธ

The paginator selected when PAGER is null or unset is partially unspecified to allow the System V historical practice of using pg as the default. Bypassing the pagination function, such as by declaring that cat is the paginator, would not meet with the intended meaning of this description. However, any ``portable user'' would have to set PAGER explicitly to get his or her preferred paginator on all systems. The paginator choice was made partially unspecified, unlike the VISUAL editor choice (mandated to be vi) because most historical pagers follow a common theme of user input, whereas editors differ dramatically. ๐Ÿ’…

Options to specify addresses as cc (carbon copy) or bcc (blind carbon copy) were considered to be format details and were omitted. yeah, sorry, they're just not here ๐Ÿซถ.

A zero exit status implies that all messages were sent, but it gives no assurances that any of them were actually delivered. The reliability of the delivery mechanism is unspecified and is an appropriate marketing distinction between systems. so likeโ€ฆ "sent" โ‰  "arrived", keep that in mind ๐Ÿ˜ญ.

In order to conform to the Utility Syntax Guidelines, a solution was required to the optional file option-argument to -f. By making file an operand, the guidelines are satisfied and users remain portable. However, it does force implementations to support usage such as:

mailx -fin mymail.box

The no name method of unsetting variables is not present in all historical systems, but it is in System V and provides a logical set of commands corresponding to the format of the display of options from the mailx set command without arguments.

The ask and asksub variables are the names selected by BSD and System V, respectively, for the same feature. They are synonyms in this volume of POSIX.1โ€2017. two names, one vibe ๐Ÿ’œ.

The mailx echo command was not documented in the BSD version and has been omitted here because it is not obviously useful for interactive users.

The default prompt on the System V mailx is a <question-mark>, on BSD Mail an <ampersand>. Since this volume of POSIX.1โ€2017 chose the mailx name, it kept the System V default, assuming that BSD users would not have difficulty with this minor incompatibility (that they can override). ๐Ÿคท

The meanings of r and R are reversed between System V mailx and SunOS Mail. Once again, since this volume of POSIX.1โ€2017 chose the mailx name, it kept the System V default, but allows the SunOS user to achieve the desired results using flipr, an internal variable in System V mailx, although it has not been documented in the SVID. ๐Ÿ˜ญ classic.

The indentprefix variable, the retain and unalias commands, and the ~F and ~M command escapes were adopted from 4.3 BSD Mail. ๐ŸŽ€

The version command was not included because no sufficiently general specification of the version information could be devised that would still be useful to a portable user. This command name should be used by suppliers who wish to provide version information about the mailx command.

The ``implementation-specific (unspecified) system start-up file'' historically has been named /etc/mailx.rc, but this specific name and location are not required.

The intent of the wording for the next command is that if any command has already displayed the current message it should display a following message, but, otherwise, it should display the current message. Consider the command sequence:

next 3
delete 3
next

where the autoprint option was not set. The normative text specifies that the second next command should display a message following the third message, because even though the current message has not been displayed since it was set by the delete command, it has been displayed since the current message was anything other than message number 3. This does not always match historical practice in some implementations, where the command file address followed by next (or the default command) would skip the message for which the user had searched. ๐Ÿ™ˆ

๐Ÿ”ฎ FUTURE DIRECTIONS ๐Ÿ”ฎ

None. (iconic, honestly. nothing coming. periodt.)

๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

  • Chapter 2, Shell Command Language, ed, ls, more, vi

The Base Definitions volume of POSIX.1โ€2017, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines

okay bestie, legal era incoming, but it's actually important so stay with me ๐Ÿซถ

Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. Like, that's the whole credit line, no skipping โœจ

real talk: if there's any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. periodt. the original is the main character, this is the cover ๐Ÿ’…

The original Standard can be obtained online at http://www.opengroup.org/unix/online.html . ๐ŸŒ


Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html . ๐Ÿ›

ngl if you spot a weirdo typo, it's almost definitely a glow-up-gone-wrong moment from the file conversion, not the original. rat it out at that link and we move on ๐Ÿ™ˆ

and that's the whole page bestie, we made it to the end ๐ŸŽ€ this gorgeous thing comes from IEEE/The Open Group, dated 2017, and it lives in the manual as MAILX(1POSIX) ๐Ÿ’œ ty for reading all of it, you're iconic, no cap ๐Ÿ‘‘๐Ÿ’–โœจ

๐Ÿ“ฆ where this page comes from