1MAILX(1P)                  POSIX Programmer's Manual                 MAILX(1P)
2
3
4

PROLOG

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

NAME

12       mailx — process messages
13

SYNOPSIS

15   Send Mode
16           mailx [-s subject] address...
17
18   Receive Mode
19           mailx -e
20
21           mailx [-HiNn] [-F] [-u user]
22
23           mailx -f [-HiNn] [-F] [file]
24

DESCRIPTION

26       The mailx utility provides a message sending and receiving facility. It
27       has  two  major  modes,  selected  by  the  options used: Send Mode and
28       Receive Mode.
29
30       On systems that do not support the User Portability  Utilities  option,
31       an  application  using mailx shall have the ability to send messages in
32       an unspecified manner (Send Mode). Unless the first character of one or
33       more  lines is <tilde> ('~'), all characters in the input message shall
34       appear in the delivered  message,  but  additional  characters  may  be
35       inserted in the message before it is retrieved.
36
37       On  systems  supporting  the  User  Portability Utilities option, mail-
38       receiving capabilities and other interactive  features,  Receive  Mode,
39       described below, also shall be enabled.
40
41   Send Mode
42       Send  Mode  can  be used by applications or users to send messages from
43       the text in standard input.
44
45   Receive Mode
46       Receive Mode is more oriented towards interactive users.  Mail  can  be
47       read and sent in this interactive mode.
48
49       When reading mail, mailx provides commands to facilitate saving, delet‐
50       ing, and responding to messages. When sending mail, mailx allows  edit‐
51       ing, reviewing, and other modification of the message as it is entered.
52
53       Incoming  mail shall be stored in one or more unspecified locations for
54       each user, collectively called the system mailbox for that  user.  When
55       mailx  is  invoked  in  Receive  Mode,  the system mailbox shall be the
56       default place to find new mail. As messages are  read,  they  shall  be
57       marked  to  be  moved  to a secondary file for storage, unless specific
58       action is taken. This secondary file is called the mbox and is normally
59       located  in  the directory referred to by the HOME environment variable
60       (see MBOX in the ENVIRONMENT VARIABLES section  for  a  description  of
61       this  file).   Messages  shall  remain  in  this  file until explicitly
62       removed. When the -f option is used to read  mail  messages  from  sec‐
63       ondary files, messages shall be retained in those files unless specifi‐
64       cally removed. All three of these locations—system mailbox,  mbox,  and
65       secondary file—are referred to in this section as simply ``mailboxes'',
66       unless more specific identification is required.
67

OPTIONS

69       The mailx utility shall conform  to  the  Base  Definitions  volume  of
70       POSIX.1‐2017, Section 12.2, Utility Syntax Guidelines.
71
72       The  following  options shall be supported. (Only the -s subject option
73       shall be required on all systems. The other options are  required  only
74       on systems supporting the User Portability Utilities option.)
75
76       -e        Test  for  the  presence  of  mail in the system mailbox. The
77                 mailx utility shall write nothing and exit with a  successful
78                 return code if there is mail to read.
79
80       -f        Read messages from the file named by the file operand instead
81                 of the system mailbox. (See also folder.)  If no file operand
82                 is  specified,  read messages from mbox instead of the system
83                 mailbox.
84
85       -F        Record the message in a file named after the first recipient.
86                 The name is the login-name portion of the address found first
87                 on the To: line in the  mail  header.  Overrides  the  record
88                 variable, if set (see Internal Variables in mailx).
89
90       -H        Write a header summary only.
91
92       -i        Ignore interrupts. (See also ignore.)
93
94       -n        Do  not initialize from the system default start-up file. See
95                 the EXTENDED DESCRIPTION section.
96
97       -N        Do not write an initial header summary.
98
99       -s subject
100                 Set the Subject header field to subject.  All  characters  in
101                 the subject string shall appear in the delivered message. The
102                 results are unspecified if subject is longer than  {LINE_MAX}
103                 - 10 bytes or contains a <newline>.
104
105       -u user   Read  the  system mailbox of the login name user.  This shall
106                 only be successful if the invoking user has appropriate priv‐
107                 ileges to read the system mailbox of that user.
108

OPERANDS

110       The following operands shall be supported:
111
112       address   Addressee of message. When -n is specified and no user start-
113                 up files are accessed (see the EXTENDED DESCRIPTION section),
114                 the  user  or  application shall ensure this is an address to
115                 pass to the mail delivery system. Any system or user start-up
116                 files  may enable aliases (see alias under Commands in mailx)
117                 that may modify the form of address before it  is  passed  to
118                 the mail delivery system.
119
120       file      A pathname of a file to be read instead of the system mailbox
121                 when -f is specified. The meaning of the file option-argument
122                 shall  be  affected  by  the  contents of the folder internal
123                 variable; see Internal Variables in mailx.
124

STDIN

126       When mailx is invoked in Send Mode (the first synopsis line),  standard
127       input  shall be the message to be delivered to the specified addresses.
128       When in Receive Mode, user commands shall be accepted from  stdin.   If
129       the  User Portability Utilities option is not supported, standard input
130       lines beginning with a  <tilde>  ('~')  character  produce  unspecified
131       results.
132
133       If  the  User  Portability  Utilities option is supported, then in both
134       Send and Receive Modes, standard input lines beginning with the  escape
135       character  (usually <tilde> ('~')) shall affect processing as described
136       in Command Escapes in mailx.
137

INPUT FILES

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

ENVIRONMENT VARIABLES

146       Some of the functionality described in this section shall  be  provided
147       on  implementations  that support the User Portability Utilities option
148       as described in the text, and is not further shaded for this option.
149
150       The following environment  variables  shall  affect  the  execution  of
151       mailx:
152
153       DEAD      Determine  the  pathname of the file in which to save partial
154                 messages in  case  of  interrupts  or  delivery  errors.  The
155                 default  shall  be  dead.letter in the directory named by the
156                 HOME variable. The behavior of mailx in saving  partial  mes‐
157                 sages is unspecified if the User Portability Utilities option
158                 is not supported and DEAD  is  not  defined  with  the  value
159                 /dev/null.
160
161       EDITOR    Determine  the name of a utility to invoke when the edit (see
162                 Commands in mailx) or ~e (see Command Escapes in mailx)  com‐
163                 mand is used. The default editor is unspecified.  On XSI-con‐
164                 formant systems it is ed.  The effects of this  variable  are
165                 unspecified  if  the User Portability Utilities option is not
166                 supported.
167
168       HOME      Determine the pathname of the user's home directory.
169
170       LANG      Provide a default value for  the  internationalization  vari‐
171                 ables  that are unset or null. (See the Base Definitions vol‐
172                 ume of POSIX.1‐2017, Section 8.2, Internationalization  Vari‐
173                 ables  for  the  precedence of internationalization variables
174                 used to determine the values of locale categories.)
175
176       LC_ALL    If set to a non-empty string value, override  the  values  of
177                 all the other internationalization variables.
178
179       LC_CTYPE  Determine  the  locale for the interpretation of sequences of
180                 bytes of text data as characters (for example, single-byte as
181                 opposed  to  multi-byte  characters  in  arguments  and input
182                 files) and  the  handling  of  case-insensitive  address  and
183                 header-field comparisons.
184
185       LC_TIME   This  variable  may  determine the format and contents of the
186                 date and time strings  written  by  mailx.   This  volume  of
187                 POSIX.1‐2017  specifies the effects of this variable only for
188                 systems supporting the User Portability Utilities option.
189
190       LC_MESSAGES
191                 Determine the locale that should be used to affect the format
192                 and contents of diagnostic messages written to standard error
193                 and informative messages written to standard output.
194
195       LISTER    Determine a string representing the command for  writing  the
196                 contents  of the folder directory to standard output when the
197                 folders command is given (see folders in Commands in  mailx).
198                 Any  string  acceptable as a command_string operand to the sh
199                 -c command shall be valid. If this variable is  null  or  not
200                 set,  the  output  command  shall be ls.  The effects of this
201                 variable are unspecified if the  User  Portability  Utilities
202                 option is not supported.
203
204       MAILRC    Determine the pathname of the user start-up file. The default
205                 shall be .mailrc in the directory referred  to  by  the  HOME
206                 environment variable. The behavior of mailx is unspecified if
207                 the User Portability Utilities option is  not  supported  and
208                 MAILRC is not defined with the value /dev/null.
209
210       MBOX      Determine  a  pathname  of the file to save messages from the
211                 system mailbox that have been read. The  exit  command  shall
212                 override  this  function, as shall saving the message explic‐
213                 itly in another file. The default shall be mbox in the direc‐
214                 tory named by the HOME variable. The effects of this variable
215                 are unspecified if the User Portability Utilities  option  is
216                 not supported.
217
218       NLSPATH   Determine the location of message catalogs for the processing
219                 of LC_MESSAGES.
220
221       PAGER     Determine a string representing an output filtering or  pagi‐
222                 nation  command  for  writing the output to the terminal. Any
223                 string acceptable as a command_string operand to  the  sh  -c
224                 command  shall  be  valid. When standard output is a terminal
225                 device, the message output shall be piped through the command
226                 if the mailx internal variable crt is set to a value less the
227                 number of lines in the message;  see  Internal  Variables  in
228                 mailx.  If the PAGER variable is null or not set, the pagina‐
229                 tor shall be either more or another paginator  utility  docu‐
230                 mented  in  the  system  documentation.   The effects of this
231                 variable are unspecified if the  User  Portability  Utilities
232                 option is not supported.
233
234       SHELL     Determine  the  name  of a preferred command interpreter. The
235                 default shall be  sh.   The  effects  of  this  variable  are
236                 unspecified  if  the User Portability Utilities option is not
237                 supported.
238
239       TERM      If the internal variable screen is not  specified,  determine
240                 the  name  of the terminal type to indicate in an unspecified
241                 manner the number of lines in a  screenful  of  headers.   If
242                 TERM  is  not  set  or is set to null, an unspecified default
243                 terminal type shall be used and the value of a  screenful  is
244                 unspecified.  The effects of this variable are unspecified if
245                 the User Portability Utilities option is not supported.
246
247       TZ        This variable may determine the timezone  used  to  calculate
248                 date  and  time  strings written by mailx.  If TZ is unset or
249                 null, an unspecified default timezone shall be used.
250
251       VISUAL    Determine a pathname of a utility to invoke when  the  visual
252                 command  (see  Commands  in  mailx) or ~v command-escape (see
253                 Command Escapes in mailx) is used. If this variable  is  null
254                 or  not set, the full-screen editor shall be vi.  The effects
255                 of this variable are  unspecified  if  the  User  Portability
256                 Utilities option is not supported.
257

ASYNCHRONOUS EVENTS

259       When  mailx  is  in  Send Mode and standard input is not a terminal, it
260       shall take the standard action for all signals.
261
262       In Receive Mode, or in Send Mode when standard input is a terminal,  if
263       a SIGINT signal is received:
264
265        1. If  in command mode, the current command, if there is one, shall be
266           aborted, and a command-mode prompt shall be written.
267
268        2. If in input mode:
269
270            a. If ignore is set, mailx shall write "@\n", discard the  current
271               input  line,  and  continue  processing, bypassing the message-
272               abort mechanism described in item 2b.
273
274            b. If the interrupt was received while sending mail,  either  when
275               in  Receive  Mode  or in Send Mode, a message shall be written,
276               and another subsequent interrupt,  with  no  other  intervening
277               characters  typed, shall be required to abort the mail message.
278               If in Receive Mode and another interrupt is  received,  a  com‐
279               mand-mode prompt shall be written.  If in Send Mode and another
280               interrupt is received, mailx shall terminate  with  a  non-zero
281               status.
282
283               In both cases listed in item b, if the message is not empty:
284
285                i.  If  save is enabled and the file named by DEAD can be cre‐
286                    ated, the message shall be written to the  file  named  by
287                    DEAD.  If the file exists, the message shall be written to
288                    replace the contents of the file.
289
290               ii.  If save is not enabled, or the file named by  DEAD  cannot
291                    be created, the message shall not be saved.
292
293       The mailx utility shall take the standard action for all other signals.
294

STDOUT

296       In command and input modes, all output, including prompts and messages,
297       shall be written to standard output.
298

STDERR

300       The standard error shall be used only for diagnostic messages.
301

OUTPUT FILES

303       Various mailx commands and command escapes can create or add to  files,
304       including the mbox, the dead-letter file, and secondary mailboxes. When
305       mailx is used as described in this volume of POSIX.1‐2017, these  files
306       shall be text files, formatted as follows:
307
308              line beginning with From<space>
309              [one or more header-lines; see Commands in mailx]
310              empty line
311              [zero or more body lines
312              empty line]
313              [line beginning with From<space>...]
314
315       where each message begins with the From <space> line shown, preceded by
316       the beginning of the file or an empty line.  (The From <space> line  is
317       considered to be part of the message header, but not one of the header-
318       lines referred to in Commands in mailx; thus, it shall not be  affected
319       by the discard, ignore, or retain commands.) The formats of the remain‐
320       der of the From <space>  line  and  any  additional  header  lines  are
321       unspecified,  except  that none shall be empty. The format of a message
322       body line is also unspecified, except that no line following  an  empty
323       line  shall  start with From <space>; mailx shall modify any such user-
324       entered message body lines (following an empty line and beginning  with
325       From  <space>)  by adding one or more characters to precede the 'F'; it
326       may add these characters to From <space> lines that are not preceded by
327       an empty line.
328
329       When  a message from the system mailbox or entered by the user is not a
330       text file, it is implementation-defined how such a message is stored in
331       files written by mailx.
332

EXTENDED DESCRIPTION

334       The  functionality  in the entire EXTENDED DESCRIPTION section shall be
335       provided on implementations supporting the User  Portability  Utilities
336       option.   The functionality described in this section shall be provided
337       on implementations that support the User Portability  Utilities  option
338       (and the rest of this section is not further shaded for this option).
339
340       The  mailx  utility need not support for all character encodings in all
341       circumstances. For example, inter-system  mail  may  be  restricted  to
342       7-bit  data  by the underlying network, 8-bit data need not be portable
343       to non-internationalized systems, and so on. Under these circumstances,
344       it  is recommended that only characters defined in the ISO/IEC 646:1991
345       standard International Reference Version (equivalent  to  ASCII)  7-bit
346       range of characters be used.
347
348       When  mailx is invoked using one of the Receive Mode synopsis forms, it
349       shall write a page of header-summary lines (if -N was not specified and
350       there  are  messages,  see below), followed by a prompt indicating that
351       mailx can accept regular commands (see  Commands  in  mailx);  this  is
352       termed  command  mode.   The page of header-summary lines shall contain
353       the first new message if there are new messages, or  the  first  unread
354       message  if there are unread messages, or the first message. When mailx
355       is invoked using the Send Mode synopsis and standard input is a  termi‐
356       nal,  if  no  subject  is  specified on the command line and the asksub
357       variable is set, a prompt for the subject shall  be  written.  At  this
358       point,  mailx  shall  be  in  input mode. This input mode shall also be
359       entered when using one of the Receive Mode synopsis forms and  a  reply
360       or  new message is composed using the reply, Reply, followup, Followup,
361       or mail commands and standard input is a terminal. When the message  is
362       typed  and  the end of the message is encountered, the message shall be
363       passed to the mail delivery software. Commands can be entered by begin‐
364       ning  a line with the escape character (by default, <tilde> ('~')) fol‐
365       lowed by a single command letter and optional arguments.  See  Commands
366       in mailx for a summary of these commands. It is unspecified what effect
367       these commands will have if standard input is not  a  terminal  when  a
368       message  is  entered  using  either the Send Mode synopsis, or the Read
369       Mode commands reply, Reply, followup, Followup, or mail.
370
371       Note:     For notational convenience, this  section  uses  the  default
372                 escape character, <tilde>, in all references and examples.
373
374       At  any time, the behavior of mailx shall be governed by a set of envi‐
375       ronmental and internal variables.  These are flags and  valued  parame‐
376       ters that can be set and cleared via the mailx set and unset commands.
377
378       Regular commands are of the form:
379
380
381           [command] [msglist] [argument ...]
382
383       If  no  command is specified in command mode, next shall be assumed. In
384       input mode, commands shall be recognized by the escape  character,  and
385       lines not treated as commands shall be taken as input for the message.
386
387       In  command  mode,  each message shall be assigned a sequential number,
388       starting with 1.
389
390       All messages have a state that shall affect how they are  displayed  in
391       the  header  summary and how they are retained or deleted upon termina‐
392       tion of mailx.  There is at any time the notion of a  current  message,
393       which shall be marked by a '>' at the beginning of a line in the header
394       summary. When mailx is invoked using one of the Receive  Mode  synopsis
395       forms,  the current message shall be the first new message, if there is
396       a new message, or the first unread message if there is an  unread  mes‐
397       sage, or the first message if there are any messages, or unspecified if
398       there are no messages in  the  mailbox.  Each  command  that  takes  an
399       optional list of messages (msglist) or an optional single message (mes‐
400       sage) on which to operate shall leave the current message  set  to  the
401       highest-numbered  message of the messages specified, unless the command
402       deletes messages, in which case the current message shall be set to the
403       first  undeleted  message (that is, a message not in the deleted state)
404       after the highest-numbered message  deleted  by  the  command,  if  one
405       exists, or the first undeleted message before the highest-numbered mes‐
406       sage deleted by the command, if one exists, or to an unspecified  value
407       if  there are no remaining undeleted messages. All messages shall be in
408       one of the following states:
409
410       new       The message is present in the system mailbox and has not been
411                 viewed  by  the user or moved to any other state. Messages in
412                 state new when mailx quits shall be retained  in  the  system
413                 mailbox.
414
415       unread    The  message  has been present in the system mailbox for more
416                 than one invocation of mailx and has not been viewed  by  the
417                 user  or  moved to any other state.  Messages in state unread
418                 when mailx quits shall be retained in the system mailbox.
419
420       read      The message has been processed by one of the  following  com‐
421                 mands:  ~f, ~m, ~F, ~M, copy, mbox, next, pipe, print, Print,
422                 top, type, Type, undelete.  The delete, dp, and  dt  commands
423                 may also cause the next message to be marked as read, depend‐
424                 ing on the value of the autoprint variable. Messages that are
425                 in  the  system  mailbox  and  in state read when mailx quits
426                 shall be saved in the mbox, unless the internal variable hold
427                 was  set.  Messages  that  are  in the mbox or in a secondary
428                 mailbox and in state read when mailx quits shall be  retained
429                 in their current location.
430
431       deleted   The  message  has been processed by one of the following com‐
432                 mands: delete, dp, dt.  Messages in state deleted when  mailx
433                 quits  shall  be  deleted.  Deleted messages shall be ignored
434                 until mailx quits or changes mailboxes or they are  specified
435                 to  the undelete command; for example, the message specifica‐
436                 tion /string shall only search the subject lines of  messages
437                 that  have not yet been deleted, unless the command operating
438                 on the list of messages is undelete.  No deleted  message  or
439                 deleted  message  header shall be displayed by any mailx com‐
440                 mand other than undelete.
441
442       preserved The message has been processed by a  preserve  command.  When
443                 mailx  quits,  the  message  shall be retained in its current
444                 location.
445
446       saved     The message has been processed by one of the  following  com‐
447                 mands:  save  or write.  If the current mailbox is the system
448                 mailbox, and the internal variable keepsave is set,  messages
449                 in  the  state saved shall be saved to the file designated by
450                 the MBOX variable (see the ENVIRONMENT VARIABLES section). If
451                 the  current  mailbox  is the system mailbox, messages in the
452                 state saved shall be deleted from the current  mailbox,  when
453                 the quit or file command is used to exit the current mailbox.
454
455       The  header-summary  line  for each message shall indicate the state of
456       the message.
457
458       Many commands take an optional list of messages (msglist) on  which  to
459       operate,  which defaults to the current message. A msglist is a list of
460       message specifications  separated  by  <blank>  characters,  which  can
461       include:
462
463       n       Message number n.
464
465       +       The next undeleted message, or the next deleted message for the
466               undelete command.
467
468       -       The next previous  undeleted  message,  or  the  next  previous
469               deleted message for the undelete command.
470
471       .       The current message.
472
473       ^       The  first  undeleted message, or the first deleted message for
474               the undelete command.
475
476       $       The last message.
477
478       *       All messages.
479
480       n‐m     An inclusive range of message numbers.
481
482       address All messages from address; any address as  shown  in  a  header
483               summary shall be matchable in this form.
484
485       /string All messages with string in the subject line (case ignored).
486
487       :c      All messages of type c, where c shall be one of:
488
489               d     Deleted messages.
490
491               n     New messages.
492
493               o     Old messages (any not in state read or new).
494
495               r     Read messages.
496
497               u     Unread messages.
498
499       Other  commands take an optional message (message) on which to operate,
500       which defaults to the current message. All of  the  forms  allowed  for
501       msglist  are  also allowed for message, but if more than one message is
502       specified, only the first shall be operated on.
503
504       Other arguments are usually arbitrary strings whose  usage  depends  on
505       the command involved.
506
507   Start-Up in mailx
508       At start-up time, mailx shall take the following steps in sequence:
509
510        1. Establish all variables at their stated default values.
511
512        2. Process command line options, overriding corresponding default val‐
513           ues.
514
515        3. Import any of the DEAD, EDITOR, MBOX, LISTER, PAGER, SHELL, or VIS‐
516           UAL  variables  that are present in the environment, overriding the
517           corresponding default values.
518
519        4. Read mailx commands  from  an  unspecified  system  start-up  file,
520           unless  the  -n  option  is given, to initialize any internal mailx
521           variables and aliases.
522
523        5. Process the user start-up file of mailx commands named in the  user
524           MAILRC variable.
525
526       Most  regular  mailx commands are valid inside start-up files, the most
527       common use being to set up initial display options and alias lists. The
528       following  commands shall be invalid in a start-up file: !, edit, hold,
529       mail, preserve, reply, Reply, shell, visual, Copy, followup,  and  Fol‐
530       lowup.   Any errors in a start-up file shall either cause mailx to ter‐
531       minate with a diagnostic message and a non-zero status or  to  continue
532       after writing a diagnostic message, ignoring the remainder of the lines
533       in the file.
534
535       A blank line in a start-up file shall be ignored.
536
537   Internal Variables in mailx
538       The following variables are internal  mailx  variables.  Each  internal
539       variable  can  be  set via the mailx set command at any time. The unset
540       and set no name commands can be used to erase variables.
541
542       In the following list, variables shown as:
543
544
545           variable
546
547       represent Boolean values. Variables shown as:
548
549
550           variable=value
551
552       shall be assigned string or numeric  values.  For  string  values,  the
553       rules  in Commands in mailx concerning filenames and quoting shall also
554       apply.
555
556       The defaults specified here may be changed by  the  unspecified  system
557       start-up file unless the user specifies the -n option.
558
559       allnet    All  network names whose login name components match shall be
560                 treated as identical. This shall cause  the  msglist  message
561                 specifications  to  behave  similarly.  The  default shall be
562                 noallnet.  See also the  alternates  command  and  the  metoo
563                 variable.
564
565       append    Append  messages to the end of the mbox file upon termination
566                 instead of placing them at the beginning. The  default  shall
567                 be noappend.  This variable shall not affect the save command
568                 when saving to mbox.
569
570       ask, asksub
571                 Prompt for a subject line on outgoing  mail  if  one  is  not
572                 specified on the command line with the -s option. The ask and
573                 asksub forms are synonyms; the system shall refer  to  asksub
574                 and  noasksub in its messages, but shall accept ask and noask
575                 as user input to mean asksub and noasksub.  It shall  not  be
576                 possible  to  set both ask and noasksub, or noask and asksub.
577                 The default shall be asksub, but no prompting shall  be  done
578                 if standard input is not a terminal.
579
580       askbcc    Prompt  for  the  blind  copy  list.  The  default  shall  be
581                 noaskbcc.
582
583       askcc     Prompt for the copy list. The default shall be noaskcc.
584
585       autoprint Enable  automatic  writing  of  messages  after  delete   and
586                 undelete commands. The default shall be noautoprint.
587
588       bang      Enable the special-case treatment of <exclamation-mark> char‐
589                 acters ('!')  in escape command lines; see the escape command
590                 and  Command  Escapes in mailx.  The default shall be nobang,
591                 disabling the expansion of '!'  in the  command  argument  to
592                 the ~!  command and the ~<!command escape.
593
594       cmd=command
595                 Set  the  default  command to be invoked by the pipe command.
596                 The default shall be nocmd.
597
598       crt=number
599                 Pipe messages having more than number lines through the  com‐
600                 mand  specified  by  the  value  of  the  PAGER variable. The
601                 default shall be nocrt.  If it is set to null, the value used
602                 is implementation-defined.
603
604       debug     Enable  verbose  diagnostics  for debugging. Messages are not
605                 delivered.  The default shall be nodebug.
606
607       dot       When dot is set, a <period> on a line by itself  during  mes‐
608                 sage input from a terminal shall also signify end-of-file (in
609                 addition to normal end-of-file). The default shall be  nodot.
610                 If  ignoreeof is set (see below), a setting of nodot shall be
611                 ignored and the <period> is  the  only  method  to  terminate
612                 input mode.
613
614       escape=c  Set the command escape character to be the character 'c'.  By
615                 default, the command escape character shall be  <tilde>.   If
616                 escape is unset, <tilde> shall be used; if it is set to null,
617                 command escaping shall be disabled.
618
619       flipr     Reverse the meanings of the R and  r  commands.  The  default
620                 shall be noflipr.
621
622       folder=directory
623                 The  default  directory for saving mail files. User-specified
624                 filenames  beginning  with  a  <plus-sign>  ('+')  shall   be
625                 expanded  by  preceding the filename with this directory name
626                 to obtain the real pathname. If directory does not start with
627                 a  <slash>  ('/'),  the contents of HOME shall be prefixed to
628                 it. The default shall be nofolder.  If folder is unset or set
629                 to  null,  user-specified  filenames beginning with '+' shall
630                 refer to files in the current directory that begin  with  the
631                 literal  '+'  character. See also outfolder below. The folder
632                 value need not affect the processing of the  files  named  in
633                 MBOX and DEAD.
634
635       header    Enable  writing  of the header summary when entering mailx in
636                 Receive Mode. The default shall be header.
637
638       hold      Preserve all messages that are read  in  the  system  mailbox
639                 instead  of  putting  them in the mbox save file. The default
640                 shall be nohold.
641
642       ignore    Ignore interrupts while entering messages. The default  shall
643                 be noignore.
644
645       ignoreeof Ignore  normal end-of-file during message input. Input can be
646                 terminated only by entering a <period> ('.')  on  a  line  by
647                 itself  or  by  the  ~.  command escape. The default shall be
648                 noignoreeof.  See also dot above.
649
650       indentprefix=string
651                 A string that shall be added as a prefix to each line that is
652                 inserted  into  the  message  by  the ~m command escape. This
653                 variable shall default to one <tab>.
654
655       keep      When a system mailbox, secondary mailbox, or mbox  is  empty,
656                 truncate  it  to  zero  length  instead  of  removing it. The
657                 default shall be nokeep.
658
659       keepsave  Keep the messages that have been saved from the system  mail‐
660                 box  into  other files in the file designated by the variable
661                 MBOX, instead of deleting them. The default shall be  nokeep‐
662                 save.
663
664       metoo     Suppress  the deletion of the login name of the user from the
665                 recipient list when replying to a message  or  sending  to  a
666                 group. The default shall be nometoo.
667
668       onehop    When responding to a message that was originally sent to sev‐
669                 eral recipients, the other recipient addresses  are  normally
670                 forced to be relative to the originating author's machine for
671                 the response. This flag disables alteration  of  the  recipi‐
672                 ents'  addresses, improving efficiency in a network where all
673                 machines can send directly to all other  machines  (that  is,
674                 one hop away). The default shall be noonehop.
675
676       outfolder Cause  the  files  used  to  record  outgoing  messages to be
677                 located in the directory specified  by  the  folder  variable
678                 unless  the pathname is absolute. The default shall be noout‐
679                 folder.  See the record variable.
680
681       page      Insert a <form-feed> after each message sent through the pipe
682                 created by the pipe command. The default shall be nopage.
683
684       prompt=string
685                 Set  the command-mode prompt to string.  If string is null or
686                 if noprompt is set, no prompting  shall  occur.  The  default
687                 shall be to prompt with the string "? ".
688
689       quiet     Refrain  from  writing  the  opening message and version when
690                 entering mailx.  The default shall be noquiet.
691
692       record=file
693                 Record all outgoing mail in the file with the pathname  file.
694                 The default shall be norecord.  See also outfolder above.
695
696       save      Enable  saving  of messages in the dead-letter file on inter‐
697                 rupt or delivery error. See the variable DEAD for  the  loca‐
698                 tion of the dead-letter file. The default shall be save.
699
700       screen=number
701                 Set  the  number  of  lines in a screenful of headers for the
702                 headers and z commands. If screen is not specified,  a  value
703                 based on the terminal type identified by the TERM environment
704                 variable, the window size, the baud rate, or some combination
705                 of these shall be used.
706
707       sendwait  Wait  for  the  background mailer to finish before returning.
708                 The default shall be nosendwait.
709
710       showto    When the sender of the message was the user who  is  invoking
711                 mailx, write the information from the To: line instead of the
712                 From: line in  the  header  summary.  The  default  shall  be
713                 noshowto.
714
715       sign=string
716                 Set the variable inserted into the text of a message when the
717                 ~a command escape is given. The default shall be nosign.  The
718                 character  sequences '\t' and '\n' shall be recognized in the
719                 variable as <tab>  and  <newline>  characters,  respectively.
720                 (See also ~i in Command Escapes in mailx.)
721
722       Sign=string
723                 Set the variable inserted into the text of a message when the
724                 ~A command escape is given. The default shall be noSign.  The
725                 character  sequences '\t' and '\n' shall be recognized in the
726                 variable as <tab> and <newline> characters, respectively.
727
728       toplines=number
729                 Set the number of lines of the message to write with the  top
730                 command. The default shall be 5.
731
732   Commands in mailx
733       The  following mailx commands shall be provided. In the following list,
734       header refers to lines from the message header, as shown in the  OUTPUT
735       FILES  section.   Header-line  refers  to  lines within the header that
736       begin with one or more non-white-space characters, immediately followed
737       by  a <colon> and white space and continuing until the next line begin‐
738       ning with a non-white-space character or an  empty  line.  Header-field
739       refers  to  the  portion of a header line prior to the first <colon> in
740       that line.
741
742       For each of the commands listed below, the command can  be  entered  as
743       the abbreviation (those characters in the Synopsis command word preced‐
744       ing the '['), the full command (all characters shown  for  the  command
745       word,  omitting the '[' and ']'), or any truncation of the full command
746       down to the abbreviation. For  example,  the  exit  command  (shown  as
747       ex[it] in the Synopsis) can be entered as ex, exi, or exit.
748
749       The arguments to commands can be quoted, using the following methods:
750
751        *  An  argument  can  be enclosed between paired double-quotes ("") or
752           single-quotes (''); any  white  space,  shell  word  expansion,  or
753           <backslash> characters within the quotes shall be treated literally
754           as part of the argument. A double-quote shall be treated  literally
755           within  single-quotes  and  vice versa. These special properties of
756           the <quotation-mark> characters shall  occur  only  when  they  are
757           paired at the beginning and end of the argument.
758
759        *  A  <backslash>  outside  of the enclosing quotes shall be discarded
760           and the following character treated literally as part of the  argu‐
761           ment.
762
763        *  An  unquoted <backslash> at the end of a command line shall be dis‐
764           carded and the next line shall continue the command.
765
766       Filenames, where expected, shall be subjected to the  following  trans‐
767       formations, in sequence:
768
769        *  If the filename begins with an unquoted <plus-sign>, and the folder
770           variable is defined (see  the  folder  variable),  the  <plus-sign>
771           shall be replaced by the value of the folder variable followed by a
772           <slash>.  If the folder variable is unset or is set  to  null,  the
773           filename shall be unchanged.
774
775        *  Shell word expansions shall be applied to the filename (see Section
776           2.6, Word Expansions).  If more than a single pathname results from
777           this  expansion  and the command is expecting one file, the effects
778           are unspecified.
779
780   Declare Aliases
781       Synopsis:
782
783                     a[lias] [alias [address...]]
784                     g[roup] [alias [address...]]
785
786       Add the given addresses to the alias specified  by  alias.   The  names
787       shall  be  substituted when alias is used as a recipient address speci‐
788       fied by the user in an outgoing  message  (that  is,  other  recipients
789       addressed indirectly through the reply command shall not be substituted
790       in this manner). Mail address alias substitution shall apply only  when
791       the alias string is used as a full address; for example, when hlj is an
792       alias, hlj@posix.com does not trigger the  alias  substitution.  If  no
793       arguments are given, write a listing of the current aliases to standard
794       output. If only an alias argument is given,  write  a  listing  of  the
795       specified alias to standard output. These listings need not reflect the
796       same order of addresses that were entered.
797
798   Declare Alternatives
799       Synopsis:
800
801                     alt[ernates] name...
802
803       (See also the metoo variable.) Declare a list of alternative names  for
804       the  user's  login.  When responding to a message, these names shall be
805       removed from the list of recipients for the response. The comparison of
806       names  shall be in a case-insensitive manner. With no arguments, alter‐
807       nates shall write the current list of alternative names.
808
809   Change Current Directory
810       Synopsis:
811
812                     cd [directory]
813                     ch[dir] [directory]
814
815       Change directory. If directory is not specified, the contents  of  HOME
816       shall be used.
817
818   Copy Messages
819       Synopsis:
820
821                     c[opy] [file]
822                     c[opy] [msglist] file
823                     C[opy] [msglist]
824
825       Copy  messages  to  the file named by the pathname file without marking
826       the messages as saved. Otherwise, it shall be equivalent  to  the  save
827       command.
828
829       In  the  capitalized  form, save the specified messages in a file whose
830       name is derived from the author of the message  to  be  saved,  without
831       marking the messages as saved. Otherwise, it shall be equivalent to the
832       Save command.
833
834   Delete Messages
835       Synopsis:
836
837                     d[elete] [msglist]
838
839       Mark messages for deletion from the mailbox. The  deletions  shall  not
840       occur  until  mailx  quits  (see the quit command) or changes mailboxes
841       (see the folder command). If autoprint is set and  there  are  messages
842       remaining  after the delete command, the current message shall be writ‐
843       ten as described for the print command (see the print command);  other‐
844       wise, the mailx prompt shall be written.
845
846   Discard Header Fields
847       Synopsis:
848
849                     di[scard] [header-field...]
850                     ig[nore] [header-field...]
851
852       Suppress  the  specified header fields when writing messages. Specified
853       header-fields shall be added to the list of suppressed  header  fields.
854       Examples  of  header  fields  to  ignore are status and cc.  The fields
855       shall be included when the message is saved. The Print  and  Type  com‐
856       mands  shall  override  this  command.  The comparison of header fields
857       shall be in a case-insensitive manner. If no arguments  are  specified,
858       write a list of the currently suppressed header fields to standard out‐
859       put; the listing need not reflect the same order of header fields  that
860       were entered.
861
862       If  both  retain and discard commands are given, discard commands shall
863       be ignored.
864
865   Delete Messages and Display
866       Synopsis:
867
868                     dp [msglist]
869                     dt [msglist]
870
871       Delete the specified messages as  described  for  the  delete  command,
872       except  that  the autoprint variable shall have no effect, and the cur‐
873       rent message shall be written only if it was set to a message after the
874       last  message  deleted by the command. Otherwise, an informational mes‐
875       sage to the effect that there are no further messages  in  the  mailbox
876       shall be written, followed by the mailx prompt.
877
878   Echo a String
879       Synopsis:
880
881                     ec[ho] string ...
882
883       Echo the given strings, equivalent to the shell echo utility.
884
885   Edit Messages
886       Synopsis:
887
888                     e[dit] [msglist]
889
890       Edit  the  given  messages. The messages shall be placed in a temporary
891       file and the utility named by the EDITOR variable is  invoked  to  edit
892       each file in sequence. The default EDITOR is unspecified.
893
894       The  edit command does not modify the contents of those messages in the
895       mailbox.
896
897   Exit
898       Synopsis:
899
900                     ex[it]
901                     x[it]
902
903       Exit from mailx without changing the  mailbox.  No  messages  shall  be
904       saved in the mbox (see also quit).
905
906   Change Folder
907       Synopsis:
908
909                     fi[le] [file]
910                     fold[er] [file]
911
912       Quit  (see the quit command) from the current file of messages and read
913       in the file named by the pathname file.  If no argument is  given,  the
914       name and status of the current mailbox shall be written.
915
916       Several  unquoted  special  characters shall be recognized when used as
917       file names, with the following substitutions:
918
919       %       The system mailbox for the invoking user.
920
921       %user   The system mailbox for user.
922
923       #       The previous file.
924
925       &       The current mbox.
926
927       +file   The named file in the folder directory. (See the  folder  vari‐
928               able.)
929
930       The default file shall be the current mailbox.
931
932   Display List of Folders
933       Synopsis:
934
935                     folders
936
937       Write  the  names of the files in the directory set by the folder vari‐
938       able. The command specified by the LISTER environment variable shall be
939       used (see the ENVIRONMENT VARIABLES section).
940
941   Follow Up Specified Messages
942       Synopsis:
943
944                     fo[llowup] [message]
945                     F[ollowup] [msglist]
946
947       In  the lowercase form, respond to a message, recording the response in
948       a file whose name is derived from the author of the message.  See  also
949       the save and copy commands and outfolder.
950
951       In  the  capitalized form, respond to the first message in the msglist,
952       sending the message to the author of each message in the msglist.   The
953       subject  line  shall  be  taken from the first message and the response
954       shall be recorded in a file whose name is derived from  the  author  of
955       the first message. See also the Save and Copy commands and outfolder.
956
957       Both forms shall override the record variable, if set.
958
959   Display Header Summary for Specified Messages
960       Synopsis:
961
962                     f[rom] [msglist]
963
964       Write the header summary for the specified messages.
965
966   Display Header Summary
967       Synopsis:
968
969                     h[eaders] [message]
970
971       Write  the  page of headers that includes the message specified. If the
972       message argument is  not  specified,  the  current  message  shall  not
973       change.   However,  if  the  message argument is specified, the current
974       message shall become the message that appears at the top of the page of
975       headers  that  includes the message specified. The screen variable sets
976       the number of headers per page. See also the z command.
977
978   Help
979       Synopsis:
980
981                     hel[p]
982                     ?
983
984       Write a summary of commands.
985
986   Hold Messages
987       Synopsis:
988
989                     ho[ld] [msglist]
990                     pre[serve] [msglist]
991
992       Mark the messages in msglist to be retained in the mailbox  when  mailx
993       terminates. This shall override any commands that might previously have
994       marked the messages to be deleted. During  the  current  invocation  of
995       mailx,  only  the  delete, dp, or dt commands shall remove the preserve
996       marking of a message.
997
998   Execute Commands Conditionally
999       Synopsis:
1000
1001                     i[f] s|r
1002                     mail-commands
1003                     el[se]
1004                     mail-commands
1005                     en[dif]
1006
1007       Execute commands conditionally, where if s executes the following mail-
1008       commands,  up  to an else or endif, if the program is in Send Mode, and
1009       if r shall cause the mail-commands to be executed only in Receive Mode.
1010
1011   List Available Commands
1012       Synopsis:
1013
1014                     l[ist]
1015
1016       Write a list of all commands available. No explanation shall be given.
1017
1018   Mail a Message
1019       Synopsis:
1020
1021                     m[ail] address...
1022
1023       Mail a message to the specified addresses or aliases.
1024
1025   Direct Messages to mbox
1026       Synopsis:
1027
1028                     mb[ox] [msglist]
1029
1030       Arrange for the given messages to end up in the  mbox  save  file  when
1031       mailx  terminates  normally. See MBOX.  See also the exit and quit com‐
1032       mands.
1033
1034   Process Next Specified Message
1035       Synopsis:
1036
1037                     n[ext] [message]
1038
1039       If the current message has not been written (for example, by the  print
1040       command) since mailx started or since any other message was the current
1041       message, behave as if the print  command  was  entered.  Otherwise,  if
1042       there  is  an  undeleted message after the current message, make it the
1043       current message and behave as if the print command was entered.  Other‐
1044       wise,  an informational message to the effect that there are no further
1045       messages in the mailbox shall be written, followed by the mailx prompt.
1046       Should  the  current  message  location be the result of an immediately
1047       preceding hold, mbox, preserve, or touch command, next will act  as  if
1048       the current message has already been written.
1049
1050   Pipe Message
1051       Synopsis:
1052
1053                     pi[pe] [[msglist] command]
1054                     | [[msglist] command]
1055
1056       Pipe  the  messages  through  the given command by invoking the command
1057       interpreter specified by SHELL with  two  arguments:  -c  and  command.
1058       (See  also  sh  -c.)   The application shall ensure that the command is
1059       given as a single argument. Quoting, described previously, can be  used
1060       to  accomplish  this.  If  no  arguments are given, the current message
1061       shall be piped through the command specified by the value  of  the  cmd
1062       variable.  If the page variable is set, a <form-feed> shall be inserted
1063       after each message.
1064
1065   Display Message with Headers
1066       Synopsis:
1067
1068                     P[rint] [msglist]
1069                     T[ype] [msglist]
1070
1071       Write the specified messages, including all header lines,  to  standard
1072       output.  Override  suppression  of  lines  by  the discard, ignore, and
1073       retain commands. If crt is set, the messages longer than the number  of
1074       lines  specified by the crt variable shall be paged through the command
1075       specified by the PAGER environment variable.
1076
1077   Display Message
1078       Synopsis:
1079
1080                     p[rint] [msglist]
1081                     t[ype] [msglist]
1082
1083       Write the specified messages to standard output. If  crt  is  set,  the
1084       messages  longer than the number of lines specified by the crt variable
1085       shall be paged through the command specified by the  PAGER  environment
1086       variable.
1087
1088   Quit
1089       Synopsis:
1090
1091                     q[uit]
1092                     end-of-file
1093
1094       Terminate  mailx,  storing messages that were read in mbox (if the cur‐
1095       rent mailbox is the system mailbox and unless hold  is  set),  deleting
1096       messages that have been explicitly saved (unless keepsave is set), dis‐
1097       carding messages that have been deleted, and saving all remaining  mes‐
1098       sages in the mailbox.
1099
1100   Reply to a Message List
1101       Synopsis:
1102
1103                     R[eply] [msglist]
1104                     R[espond] [msglist]
1105
1106       Mail a reply message to the sender of each message in the msglist.  The
1107       subject line shall be formed by  concatenating  Re:<space>  (unless  it
1108       already  begins  with  that string) and the subject from the first mes‐
1109       sage. If record is set to a filename, the response shall  be  saved  at
1110       the end of that file.
1111
1112       See also the flipr variable.
1113
1114   Reply to a Message
1115       Synopsis:
1116
1117                     r[eply] [message]
1118                     r[espond] [message]
1119
1120       Mail  a  reply  message to all recipients included in the header of the
1121       message. The subject line shall be formed by  concatenating  Re:<space>
1122       (unless  it  already  begins with that string) and the subject from the
1123       message. If record is set to a filename, the response shall be saved at
1124       the end of that file.
1125
1126       See also the flipr variable.
1127
1128   Retain Header Fields
1129       Synopsis:
1130
1131                     ret[ain] [header-field...]
1132
1133       Retain  the specified header fields when writing messages. This command
1134       shall override all discard  and  ignore  commands.  The  comparison  of
1135       header  fields  shall  be in a case-insensitive manner. If no arguments
1136       are specified, write a list of the currently retained header fields  to
1137       standard  output; the listing need not reflect the same order of header
1138       fields that were entered.
1139
1140   Save Messages
1141       Synopsis:
1142
1143                     s[ave] [file]
1144                     s[ave] [msglist] file
1145                     S[ave] [msglist]
1146
1147       Save the specified messages in the file named by the pathname file,  or
1148       the  mbox if the file argument is omitted. The file shall be created if
1149       it does not exist; otherwise, the messages shall  be  appended  to  the
1150       file.  The message shall be put in the state saved, and shall behave as
1151       specified in the description of the saved state when the current  mail‐
1152       box is exited by the quit or file command.
1153
1154       In  the  capitalized  form, save the specified messages in a file whose
1155       name is derived from the author of the first message. The name  of  the
1156       file shall be taken to be the author's name with all network addressing
1157       stripped off. See also the Copy, followup, and  Followup  commands  and
1158       outfolder variable.
1159
1160   Set Variables
1161       Synopsis:
1162
1163                     se[t] [name[=[string]] ...] [name=number ...] [noname ...]
1164
1165       Define  one or more variables called name.  The variable can be given a
1166       null, string, or numeric value.  Quoting  and  <backslash>-escapes  can
1167       occur  anywhere  in  string,  as described previously, as if the string
1168       portion of the argument were the entire argument. The  forms  name  and
1169       name=  shall  be  equivalent  to name="" for variables that take string
1170       values. The set command without arguments shall write  a  list  of  all
1171       defined  variables  and their values. The no name form shall be equiva‐
1172       lent to unset name.
1173
1174   Invoke a Shell
1175       Synopsis:
1176
1177                     sh[ell]
1178
1179       Invoke an interactive command interpreter (see also SHELL).
1180
1181   Display Message Size
1182       Synopsis:
1183
1184                     si[ze] [msglist]
1185
1186       Write the size in bytes of each of the specified messages.
1187
1188   Read mailx Commands From a File
1189       Synopsis:
1190
1191                     so[urce] file
1192
1193       Read and execute commands from the file named by the pathname file  and
1194       return to command mode.
1195
1196   Display Beginning of Messages
1197       Synopsis:
1198
1199                     to[p] [msglist]
1200
1201       Write  the  top  few  lines  of  each of the specified messages. If the
1202       toplines variable is set, it is taken as the number of lines to  write.
1203       The default shall be 5.
1204
1205   Touch Messages
1206       Synopsis:
1207
1208                     tou[ch] [msglist]
1209
1210       Touch the specified messages. If any message in msglist is not specifi‐
1211       cally deleted nor saved in a file, it shall be placed in the mbox  upon
1212       normal termination. See exit and quit.
1213
1214   Delete Aliases
1215       Synopsis:
1216
1217                     una[lias] [alias]...
1218
1219       Delete  the specified alias names. If a specified alias does not exist,
1220       the results are unspecified.
1221
1222   Undelete Messages
1223       Synopsis:
1224
1225                     u[ndelete] [msglist]
1226
1227       Change the state of the specified messages from  deleted  to  read.  If
1228       autoprint  is set, the last message of those restored shall be written.
1229       If msglist is not specified, the message shall be selected as follows:
1230
1231        *  If there are any deleted messages that follow the current  message,
1232           the first of these shall be chosen.
1233
1234        *  Otherwise,  the last deleted message that also precedes the current
1235           message shall be chosen.
1236
1237   Unset Variables
1238       Synopsis:
1239
1240                     uns[et] name...
1241
1242       Cause the specified variables to be erased.
1243
1244   Edit Message with Full-Screen Editor
1245       Synopsis:
1246
1247                     v[isual] [msglist]
1248
1249       Edit the given messages with a screen editor.  Each  message  shall  be
1250       placed  in  a temporary file, and the utility named by the VISUAL vari‐
1251       able shall be invoked to edit each file in sequence. The default editor
1252       shall be vi.
1253
1254       The  visual  command  does not modify the contents of those messages in
1255       the mailbox.
1256
1257   Write Messages to a File
1258       Synopsis:
1259
1260                     w[rite] [msglist] file
1261
1262       Write the given messages to the file specified by  the  pathname  file,
1263       minus the message header. Otherwise, it shall be equivalent to the save
1264       command.
1265
1266   Scroll Header Display
1267       Synopsis:
1268
1269                     z[+|-]
1270
1271       Scroll the header display forward (if '+' is specified or if no  option
1272       is specified) or backward (if '-' is specified) one screenful. The num‐
1273       ber of headers written shall be set by the screen variable.
1274
1275   Invoke Shell Command
1276       Synopsis:
1277
1278                     !command
1279
1280       Invoke the command interpreter specified by SHELL with  two  arguments:
1281       -c  and  command.  (See also sh -c.)  If the bang variable is set, each
1282       unescaped occurrence of '!'  in command shall be replaced with the com‐
1283       mand executed by the previous !  command or ~!  command escape.
1284
1285   Null Command
1286       Synopsis:
1287
1288                     # comment
1289
1290       This null command (comment) shall be ignored by mailx.
1291
1292   Display Current Message Number
1293       Synopsis:
1294
1295                     =
1296
1297       Write the current message number.
1298
1299   Command Escapes in mailx
1300       The  following  commands can be entered only from input mode, by begin‐
1301       ning a line with the escape character (by default, <tilde> ('~')).  See
1302       the  escape  variable  description for changing this special character.
1303       The format for the commands shall be:
1304
1305
1306           <escape-character><command-char><separator>[<arguments>]
1307
1308       where the <separator> can be zero or more <blank> characters.
1309
1310       In the following descriptions, the application shall  ensure  that  the
1311       argument command (but not mailx-command) is a shell command string. Any
1312       string acceptable to the command interpreter  specified  by  the  SHELL
1313       variable  when it is invoked as SHELL -c command_string shall be valid.
1314       The command can be presented as multiple arguments (that is, quoting is
1315       not required).
1316
1317       Command escapes that are listed with msglist or mailx-command arguments
1318       are invalid in Send Mode and produce unspecified results.
1319
1320       ~! command
1321                 Invoke the command interpreter specified by  SHELL  with  two
1322                 arguments:  -c and command; and then return to input mode. If
1323                 the bang variable is set, each unescaped  occurrence  of  '!'
1324                 in command shall be replaced with the command executed by the
1325                 previous !  command or ~!  command escape.
1326
1327       ~.        Simulate end-of-file (terminate message input).
1328
1329       ~: mailx-command, ~_ mailx-command
1330                 Perform the command-level request.
1331
1332       ~?        Write a summary of command escapes.
1333
1334       ~A        This shall be equivalent to ~i Sign.
1335
1336       ~a        This shall be equivalent to ~i sign.
1337
1338       ~b name...
1339                 Add the names to the blind carbon copy (Bcc) list.
1340
1341       ~c name...
1342                 Add the names to the carbon copy (Cc) list.
1343
1344       ~d        Read in the dead-letter file. See DEAD for a  description  of
1345                 this file.
1346
1347       ~e        Invoke  the  editor,  as  specified by the EDITOR environment
1348                 variable, on the partial message.
1349
1350       ~f [msglist]
1351                 Forward the specified messages. The specified messages  shall
1352                 be inserted into the current message without alteration. This
1353                 command escape also shall insert  message  headers  into  the
1354                 message with field selection affected by the discard, ignore,
1355                 and retain commands.
1356
1357       ~F [msglist]
1358                 This shall be the equivalent of the ~f command escape, except
1359                 that all headers shall be included in the message, regardless
1360                 of previous discard, ignore, and retain commands.
1361
1362       ~h        If standard input is a terminal, prompt for  a  Subject  line
1363                 and  the  To, Cc, and Bcc lists. Other implementation-defined
1364                 headers may also be presented for editing. If  the  field  is
1365                 written  with an initial value, it can be edited as if it had
1366                 just been typed.
1367
1368       ~i string Insert the value of the named variable, followed by  a  <new‐
1369                 line>,  into  the text of the message. If the string is unset
1370                 or null, the message shall not be changed.
1371
1372       ~m [msglist]
1373                 Insert the specified messages  into  the  message,  prefixing
1374                 non-empty lines with the string in the indentprefix variable.
1375                 This command escape also shall insert  message  headers  into
1376                 the  message,  with  field selection affected by the discard,
1377                 ignore, and retain commands.
1378
1379       ~M [msglist]
1380                 This shall be the equivalent of the ~m command escape, except
1381                 that all headers shall be included in the message, regardless
1382                 of previous discard, ignore, and retain commands.
1383
1384       ~p        Write the message being entered. If  the  message  is  longer
1385                 than  crt lines (see Internal Variables in mailx), the output
1386                 shall be paginated as described for the PAGER variable.
1387
1388       ~q        Quit (see the quit command) from input mode by simulating  an
1389                 interrupt.  If the body of the message is not empty, the par‐
1390                 tial message shall be saved in the dead-letter file. See DEAD
1391                 for a description of this file.
1392
1393       ~r file, ~< file, ~r !command, ~< !command
1394                 Read  in  the  file  specified  by the pathname file.  If the
1395                 argument begins with an <exclamation-mark> ('!'), the rest of
1396                 the string shall be taken as an arbitrary system command; the
1397                 command interpreter specified by SHELL shall be invoked  with
1398                 two  arguments:  -c and command.  The standard output of com‐
1399                 mand shall be inserted into the message.
1400
1401       ~s string Set the subject line to string.
1402
1403       ~t name...
1404                 Add the given names to the To list.
1405
1406       ~v        Invoke the full-screen editor, as  specified  by  the  VISUAL
1407                 environment variable, on the partial message.
1408
1409       ~w file   Write  the partial message, without the header, onto the file
1410                 named by the pathname file.  The file shall be created or the
1411                 message shall be appended to it if the file exists.
1412
1413       ~x        Exit as with ~q, except the message shall not be saved in the
1414                 dead-letter file.
1415
1416       ~| command
1417                 Pipe the body of the message through  the  given  command  by
1418                 invoking  the command interpreter specified by SHELL with two
1419                 arguments: -c and command.  If the command returns a success‐
1420                 ful  exit  status,  the  standard output of the command shall
1421                 replace the message.  Otherwise,  the  message  shall  remain
1422                 unchanged.  If the command fails, an error message giving the
1423                 exit status shall be written.
1424

EXIT STATUS

1426       When the  -e  option  is  specified,  the  following  exit  values  are
1427       returned:
1428
1429        0    Mail was found.
1430
1431       >0    Mail was not found or an error occurred.
1432
1433       Otherwise, the following exit values are returned:
1434
1435        0    Successful  completion;  note  that  this status implies that all
1436             messages were sent, but it gives no assurances that any  of  them
1437             were actually delivered.
1438
1439       >0    An error occurred.
1440

CONSEQUENCES OF ERRORS

1442       When in input mode (Receive Mode) or Send Mode:
1443
1444        *  If  an error is encountered processing an input line beginning with
1445           a <tilde> ('~') character, (see Command Escapes in mailx), a  diag‐
1446           nostic  message shall be written to standard error, and the message
1447           being composed may be modified, but this condition shall  not  pre‐
1448           vent the message from being sent.
1449
1450        *  Other errors shall prevent the sending of the message.
1451
1452       When in command mode:
1453
1454        *  Default.
1455
1456       The following sections are informative.
1457

APPLICATION USAGE

1459       Delivery of messages to remote systems requires the existence of commu‐
1460       nication paths to such systems. These need not exist.
1461
1462       Input lines are limited to {LINE_MAX} bytes, but mailers  between  sys‐
1463       tems  may  impose  more severe line-length restrictions. This volume of
1464       POSIX.1‐2017 does not place any restrictions on the length of  messages
1465       handled  by  mailx, and for delivery of local messages the only limita‐
1466       tions should be the normal problems of available  disk  space  for  the
1467       target  mail file. When sending messages to external machines, applica‐
1468       tions are advised to limit messages to less than 100000  bytes  because
1469       some mail gateways impose message-length restrictions.
1470
1471       The  format of the system mailbox is intentionally unspecified. Not all
1472       systems implement system mailboxes as flat files, particularly with the
1473       advent of multimedia mail messages. Some system mailboxes may be multi‐
1474       ple files, others records in a database. The  internal  format  of  the
1475       messages  themselves  is specified with the historical format from Ver‐
1476       sion 7, but only after the messages have been saved in some file  other
1477       than the system mailbox. This was done so that many historical applica‐
1478       tions expecting text-file mailboxes are not broken.
1479
1480       Some new formats for messages can be expected in the  future,  probably
1481       including  binary  data,  bit  maps, and various multimedia objects. As
1482       described here, mailx is not prohibited from  handling  such  messages,
1483       but  it  must  store  them as text files in secondary mailboxes (unless
1484       some extension, such as a variable or command line option, is  used  to
1485       change  the  stored format).  Its method of doing so is implementation-
1486       defined and might include translating the data into text  file-compati‐
1487       ble  or  readable form or omitting certain portions of the message from
1488       the stored output.
1489
1490       The discard and ignore commands are not inverses of the retain command.
1491       The  retain  command discards all header-fields except those explicitly
1492       retained.  The discard command keeps  all  header-fields  except  those
1493       explicitly  discarded.  If  headers  exist on the retained header list,
1494       discard and ignore commands are ignored.
1495

EXAMPLES

1497       None.
1498

RATIONALE

1500       The standard developers felt strongly that a method for applications to
1501       send messages to specific users was necessary. The obvious example is a
1502       batch utility, running non-interactively, that  wishes  to  communicate
1503       errors or results to a user. However, the actual format, delivery mech‐
1504       anism, and method of reading the message are clearly beyond  the  scope
1505       of this volume of POSIX.1‐2017.
1506
1507       The  intent  of this command is to provide a simple, portable interface
1508       for sending messages non-interactively. It merely  defines  a  ``front-
1509       end''  to  the historical mail system. It is suggested that implementa‐
1510       tions explicitly denote the sender and recipient in  the  body  of  the
1511       delivered message. Further specification of formats for either the mes‐
1512       sage envelope or the message itself were deliberately not made, as  the
1513       industry  is  in  the midst of changing from the current standards to a
1514       more internationalized standard and it is probably incorrect,  at  this
1515       time, to require either one.
1516
1517       Implementations are encouraged to conform to the various delivery mech‐
1518       anisms described in the CCITT X.400  standards  or  to  the  equivalent
1519       Internet  standards,  described  in  Internet Request for Comment (RFC)
1520       documents RFC 819, RFC 920, RFC 921, RFC 1123, and RFC 5322 (which suc‐
1521       ceeded RFC 822).
1522
1523       Many historical systems modified each body line that started with From
1524       by prefixing the 'F' with '>'.  It is unnecessary, but allowed,  to  do
1525       that  when the string does not follow a blank line because it cannot be
1526       confused with the next header.
1527
1528       The edit and visual commands merely edit the specified  messages  in  a
1529       temporary  file.  They  do not modify the contents of those messages in
1530       the mailbox; such a capability could be added as an extension, such  as
1531       by using different command names.
1532
1533       The restriction on a subject line being {LINE_MAX}-10 bytes is based on
1534       the historical format that consumes 10  bytes  for  Subject:   and  the
1535       trailing  <newline>.   Many  historical  mailers  that  a  message  may
1536       encounter on other systems are not able to handle lines that long, how‐
1537       ever.
1538
1539       Like  the  utilities  logger  and  lp, mailx admittedly is difficult to
1540       test. This was not deemed  sufficient  justification  to  exclude  this
1541       utility  from  this volume of POSIX.1‐2017. It is also arguable that it
1542       is, in fact, testable, but that the tests themselves are not portable.
1543
1544       When mailx is being used by an application that wishes to  receive  the
1545       results  as  if  none of the User Portability Utilities option features
1546       were supported, the DEAD environment variable must be set to /dev/null.
1547       Otherwise,  it  may be subject to the file creations described in mailx
1548       ASYNCHRONOUS EVENTS. Similarly, if the MAILRC environment  variable  is
1549       not  set  to /dev/null, historical versions of mailx and Mail read ini‐
1550       tialization commands from a file before processing begins.   Since  the
1551       initialization  that  a user specifies could alter the contents of mes‐
1552       sages an application is trying to  send,  such  applications  must  set
1553       MAILRC to /dev/null.
1554
1555       The  description of LC_TIME uses ``may affect'' because many historical
1556       implementations do not or cannot manipulate the date and  time  strings
1557       in  the  incoming  mail headers. Some headers found in incoming mail do
1558       not have enough information to determine the timezone in which the mail
1559       originated,  and,  therefore,  mailx  cannot  convert the date and time
1560       strings into the internal form that then is  parsed  by  routines  like
1561       strftime()  that  can  take LC_TIME settings into account. Changing all
1562       these times to a user-specified format is allowed, but not required.
1563
1564       The paginator selected when PAGER is null or unset is partially unspec‐
1565       ified  to  allow  the  System  V historical practice of using pg as the
1566       default. Bypassing the pagination function, such as by  declaring  that
1567       cat  is the paginator, would not meet with the intended meaning of this
1568       description. However, any ``portable user'' would  have  to  set  PAGER
1569       explicitly  to  get  his or her preferred paginator on all systems. The
1570       paginator choice was made partially unspecified, unlike the VISUAL edi‐
1571       tor  choice (mandated to be vi) because most historical pagers follow a
1572       common theme of user input, whereas editors differ dramatically.
1573
1574       Options to specify addresses as cc (carbon copy) or bcc  (blind  carbon
1575       copy) were considered to be format details and were omitted.
1576
1577       A zero exit status implies that all messages were sent, but it gives no
1578       assurances that any of them were actually delivered.   The  reliability
1579       of  the delivery mechanism is unspecified and is an appropriate market‐
1580       ing distinction between systems.
1581
1582       In order to conform to the Utility Syntax Guidelines,  a  solution  was
1583       required to the optional file option-argument to -f.  By making file an
1584       operand, the guidelines are satisfied and users remain portable.   How‐
1585       ever, it does force implementations to support usage such as:
1586
1587
1588           mailx -fin mymail.box
1589
1590       The no name method of unsetting variables is not present in all histor‐
1591       ical systems, but it is in System V and provides a logical set of  com‐
1592       mands  corresponding  to  the format of the display of options from the
1593       mailx set command without arguments.
1594
1595       The ask and asksub variables are the names selected by BSD  and  System
1596       V, respectively, for the same feature. They are synonyms in this volume
1597       of POSIX.1‐2017.
1598
1599       The mailx echo command was not documented in the BSD  version  and  has
1600       been  omitted  here  because it is not obviously useful for interactive
1601       users.
1602
1603       The default prompt on the System V mailx is a <question-mark>,  on  BSD
1604       Mail an <ampersand>.  Since this volume of POSIX.1‐2017 chose the mailx
1605       name, it kept the System V default, assuming that BSD users  would  not
1606       have  difficulty  with  this minor incompatibility (that they can over‐
1607       ride).
1608
1609       The meanings of r and R are reversed between System V mailx  and  SunOS
1610       Mail.   Once  again,  since this volume of POSIX.1‐2017 chose the mailx
1611       name, it kept the System V  default,  but  allows  the  SunOS  user  to
1612       achieve the desired results using flipr, an internal variable in System
1613       V mailx, although it has not been documented in the SVID.
1614
1615       The indentprefix variable, the retain and unalias commands, and the  ~F
1616       and ~M command escapes were adopted from 4.3 BSD Mail.
1617
1618       The  version  command  was not included because no sufficiently general
1619       specification of the version information could be  devised  that  would
1620       still be useful to a portable user. This command name should be used by
1621       suppliers who wish to provide version information about the mailx  com‐
1622       mand.
1623
1624       The ``implementation-specific (unspecified) system start-up file'' his‐
1625       torically has been named /etc/mailx.rc,  but  this  specific  name  and
1626       location are not required.
1627
1628       The  intent  of the wording for the next command is that if any command
1629       has already displayed the current message it should display a following
1630       message,  but,  otherwise,  it should display the current message. Con‐
1631       sider the command sequence:
1632
1633
1634           next 3
1635           delete 3
1636           next
1637
1638       where the autoprint option was not set. The  normative  text  specifies
1639       that  the  second  next  command should display a message following the
1640       third message, because even though the current  message  has  not  been
1641       displayed since it was set by the delete command, it has been displayed
1642       since the current message was anything other  than  message  number  3.
1643       This does not always match historical practice in some implementations,
1644       where the command file address followed by next (or  the  default  com‐
1645       mand) would skip the message for which the user had searched.
1646

FUTURE DIRECTIONS

1648       None.
1649

SEE ALSO

1651       Chapter 2, Shell Command Language, ed, ls, more, vi
1652
1653       The  Base  Definitions  volume  of POSIX.1‐2017, Chapter 8, Environment
1654       Variables, Section 12.2, Utility Syntax Guidelines
1655
1657       Portions of this text are reprinted and reproduced in  electronic  form
1658       from  IEEE Std 1003.1-2017, Standard for Information Technology -- Por‐
1659       table Operating System Interface (POSIX), The Open Group Base  Specifi‐
1660       cations  Issue  7, 2018 Edition, Copyright (C) 2018 by the Institute of
1661       Electrical and Electronics Engineers, Inc and The Open Group.   In  the
1662       event of any discrepancy between this version and the original IEEE and
1663       The Open Group Standard, the original IEEE and The Open Group  Standard
1664       is  the  referee document. The original Standard can be obtained online
1665       at http://www.opengroup.org/unix/online.html .
1666
1667       Any typographical or formatting errors that appear  in  this  page  are
1668       most likely to have been introduced during the conversion of the source
1669       files to man page format. To report such errors,  see  https://www.ker
1670       nel.org/doc/man-pages/reporting_bugs.html .
1671
1672
1673
1674IEEE/The Open Group                  2017                            MAILX(1P)
Impressum