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
11

NAME

13       mailx — process messages
14

SYNOPSIS

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

DESCRIPTION

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

OPTIONS

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

OPERANDS

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

STDIN

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

INPUT FILES

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

ENVIRONMENT VARIABLES

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

ASYNCHRONOUS EVENTS

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

STDOUT

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

STDERR

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

OUTPUT FILES

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

EXTENDED DESCRIPTION

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

EXIT STATUS

1378       When the  −e  option  is  specified,  the  following  exit  values  are
1379       returned:
1380
1381        0    Mail was found.
1382
1383       >0    Mail was not found or an error occurred.
1384
1385       Otherwise, the following exit values are returned:
1386
1387        0    Successful  completion;  note  that  this status implies that all
1388             messages were sent, but it gives no assurances that any  of  them
1389             were actually delivered.
1390
1391       >0    An error occurred.
1392

CONSEQUENCES OF ERRORS

1394       When in input mode (Receive Mode) or Send Mode:
1395
1396        *  If  an error is encountered processing an input line beginning with
1397           a <tilde> ('~') character, (see Command Escapes in mailx), a  diag‐
1398           nostic  message shall be written to standard error, and the message
1399           being composed may be modified, but this condition shall  not  pre‐
1400           vent the message from being sent.
1401
1402        *  Other errors shall prevent the sending of the message.
1403
1404       When in command mode:
1405
1406        *  Default.
1407
1408       The following sections are informative.
1409

APPLICATION USAGE

1411       Delivery of messages to remote systems requires the existence of commu‐
1412       nication paths to such systems. These need not exist.
1413
1414       Input lines are limited to {LINE_MAX} bytes, but mailers  between  sys‐
1415       tems  may  impose  more severe line-length restrictions. This volume of
1416       POSIX.1‐2008 does not place any restrictions on the length of  messages
1417       handled  by  mailx, and for delivery of local messages the only limita‐
1418       tions should be the normal problems of available  disk  space  for  the
1419       target  mail file. When sending messages to external machines, applica‐
1420       tions are advised to limit messages to less than 100000  bytes  because
1421       some mail gateways impose message-length restrictions.
1422
1423       The  format of the system mailbox is intentionally unspecified. Not all
1424       systems implement system mailboxes as flat files, particularly with the
1425       advent of multimedia mail messages. Some system mailboxes may be multi‐
1426       ple files, others records in a database. The  internal  format  of  the
1427       messages  themselves  is specified with the historical format from Ver‐
1428       sion 7, but only after the messages have been saved in some file  other
1429       than the system mailbox. This was done so that many historical applica‐
1430       tions expecting text-file mailboxes are not broken.
1431
1432       Some new formats for messages can be expected in the  future,  probably
1433       including  binary  data,  bit  maps, and various multimedia objects. As
1434       described here, mailx is not prohibited from  handling  such  messages,
1435       but  it  must  store  them as text files in secondary mailboxes (unless
1436       some extension, such as a variable or command line option, is  used  to
1437       change  the  stored format).  Its method of doing so is implementation-
1438       defined and might include translating the data into text  file-compati‐
1439       ble  or  readable form or omitting certain portions of the message from
1440       the stored output.
1441
1442       The discard and ignore commands are not inverses of the retain command.
1443       The  retain  command discards all header-fields except those explicitly
1444       retained.  The discard command keeps  all  header-fields  except  those
1445       explicitly  discarded.  If  headers  exist on the retained header list,
1446       discard and ignore commands are ignored.
1447

EXAMPLES

1449       None.
1450

RATIONALE

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

FUTURE DIRECTIONS

1597       None.
1598

SEE ALSO

1600       Chapter 2, Shell Command Language, ed, ls, more, vi
1601
1602       The Base Definitions volume of  POSIX.1‐2008,  Chapter  8,  Environment
1603       Variables, Section 12.2, Utility Syntax Guidelines
1604
1606       Portions  of  this text are reprinted and reproduced in electronic form
1607       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
1608       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
1609       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
1610       cal  and  Electronics  Engineers,  Inc  and  The  Open Group.  (This is
1611       POSIX.1-2008 with the 2013 Technical Corrigendum  1  applied.)  In  the
1612       event of any discrepancy between this version and the original IEEE and
1613       The Open Group Standard, the original IEEE and The Open Group  Standard
1614       is  the  referee document. The original Standard can be obtained online
1615       at http://www.unix.org/online.html .
1616
1617       Any typographical or formatting errors that appear  in  this  page  are
1618       most likely to have been introduced during the conversion of the source
1619       files to man page format. To report such errors,  see  https://www.ker
1620       nel.org/doc/man-pages/reporting_bugs.html .
1621
1622
1623
1624IEEE/The Open Group                  2013                            MAILX(1P)
Impressum