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

NAME

6       mailx - process messages
7

SYNOPSIS

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

DESCRIPTION

26       The  mailx  utility  provides a message sending and receiving facility.
27       It 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       IEEE Std 1003.1-2001, 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  mailx
77              utility  shall  write  nothing and exit with a successful return
78              code if there is mail to read.
79
80       -f     Read messages from the file named by the file operand instead of
81              the  system  mailbox.  (See  also folder.) If no file operand is
82              specified, read messages from mbox instead of the  system  mail‐
83              box.
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 on
87              the  To: line in the mail header. Overrides the record variable,
88              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 the
95              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 the
101              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
106              Read the system mailbox of the login name user. This shall  only
107              be  successful  if  the invoking user has the appropriate privi‐
108              leges to read the system mailbox of that user.
109
110

OPERANDS

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

STDIN

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

INPUT FILES

143       When mailx is used as described by this volume of IEEE Std 1003.1-2001,
144       the file option-argument (see the -f option) and the mbox shall be text
145       files  containing  mail  messages, formatted as described in the OUTPUT
146       FILES section. The nature of the system mailbox is unspecified; it need
147       not be a file.
148

ENVIRONMENT VARIABLES

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 mes‐
154              sages  in  case  of  interrupts  or delivery errors. The default
155              shall be dead.letter in the directory named by  the  HOME  vari‐
156              able.  The  behavior  of  mailx  in  saving  partial messages is
157              unspecified if the User Portability Utilities option is not sup‐
158              ported and DEAD is not defined with the value /dev/null.
159
160       EDITOR Determine  the  name  of  a utility to invoke when the edit (see
161              Commands in mailx ) or ~e (see Command Escapes in mailx  )  com‐
162              mand  is  used. The default editor is unspecified.   On XSI-con‐
163              formant systems it is ed.  The  effects  of  this  variable  are
164              unspecified if the User Portability Utilities option is not sup‐
165              ported.
166
167       HOME   Determine the pathname of the user's home directory.
168
169       LANG   Provide a default value for the  internationalization  variables
170              that  are  unset  or  null.  (See the Base Definitions volume of
171              IEEE Std 1003.1-2001, Section  8.2,  Internationalization  Vari‐
172              ables  for the precedence of internationalization variables used
173              to determine the values of locale categories.)
174
175       LC_ALL If set to a non-empty string value, override the values  of  all
176              the other internationalization variables.
177
178       LC_CTYPE
179              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 files)
182              and the handling of case-insensitive  address  and  header-field
183              comparisons.
184
185       LC_TIME
186              Determine  the  format and contents of the date and time strings
187              written by mailx.
188
189       LC_MESSAGES
190              Determine the locale that should be used to  affect  the  format
191              and  contents  of  diagnostic messages written to standard error
192              and informative messages written to standard output.
193
194       LISTER Determine a string representing the command for writing the con‐
195              tents  of the folder directory to standard output when the fold‐
196              ers command is given (see folders in Commands in  mailx  ).  Any
197              string  acceptable as a command_string operand to the sh -c com‐
198              mand shall be valid. If this variable is null or  not  set,  the
199              output  command  shall  be ls.  The effects of this variable are
200              unspecified if the User Portability Utilities option is not sup‐
201              ported.
202
203       MAILRC Determine  the  pathname of the start-up file. The default shall
204              be .mailrc in the directory referred to by the HOME  environment
205              variable.  The  behavior  of  mailx  is  unspecified if the User
206              Portability Utilities option is not supported and MAILRC is  not
207              defined with the value /dev/null.
208
209       MBOX   Determine  a pathname of the file to save messages from the sys‐
210              tem mailbox that have been read. The exit command shall override
211              this function, as shall saving the message explicitly in another
212              file. The default shall be mbox in the directory  named  by  the
213              HOME  variable.  The effects of this variable are unspecified if
214              the User Portability Utilities option is not supported.
215
216       NLSPATH
217              Determine the location of message catalogs for the processing of
218              LC_MESSAGES .
219
220       PAGER  Determine  a  string representing an output filtering or pagina‐
221              tion command for writing the output to the terminal. Any  string
222              acceptable  as  a  command_string  operand  to the sh -c command
223              shall be valid.  When standard output is a terminal device,  the
224              message  output  shall be piped through the command if the mailx
225              internal variable crt is set to a value less the number of lines
226              in  the  message; see Internal Variables in mailx . If the PAGER
227              variable is null or not set, the paginator shall be either  more
228              or another paginator utility documented in the system documenta‐
229              tion. The effects of this variable are unspecified if  the  User
230              Portability Utilities option is not supported.
231
232       SHELL  Determine  the  name  of  a  preferred  command interpreter. The
233              default shall be sh. The effects of this variable  are  unspeci‐
234              fied if the User Portability Utilities option is not supported.
235
236       TERM   If  the internal variable screen is not specified, determine the
237              name of the terminal type to indicate in an  unspecified  manner
238              the  number  of  lines in a screenful of headers. If TERM is not
239              set or is set to null,  an  unspecified  default  terminal  type
240              shall  be  used and the value of a screenful is unspecified. The
241              effects of this variable are unspecified if the User Portability
242              Utilities option is not supported.
243
244       TZ     This  variable may determine the timezone used to calculate date
245              and time strings written by mailx. If TZ is unset  or  null,  an
246              unspecified default timezone shall be used.
247
248       VISUAL Determine a pathname of a utility to invoke when the visual com‐
249              mand (see Commands in mailx ) or ~v command-escape (see  Command
250              Escapes in mailx ) is used. If this variable is null or not set,
251              the full-screen editor shall be vi.  The effects of  this  vari‐
252              able are unspecified if the User Portability Utilities option is
253              not supported.
254
255

ASYNCHRONOUS EVENTS

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

STDOUT

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

STDERR

298       The standard error shall be used only for diagnostic messages.
299

OUTPUT FILES

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

EXTENDED DESCRIPTION

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

EXIT STATUS

1511       When the  -e  option  is  specified,  the  following  exit  values  are
1512       returned:
1513
1514        0     Mail was found.
1515
1516       >0     Mail was not found or an error occurred.
1517
1518
1519       Otherwise, the following exit values are returned:
1520
1521        0     Successful  completion;  note  that this status implies that all
1522              messages were sent, but it gives no assurances that any of  them
1523              were actually delivered.
1524
1525       >0     An error occurred.
1526
1527

CONSEQUENCES OF ERRORS

1529       When in input mode (Receive Mode) or Send Mode:
1530
1531        * If  an error is encountered processing a command escape (see Command
1532          Escapes in mailx ), a diagnostic message shall be written  to  stan‐
1533          dard error, and the message being composed may be modified, but this
1534          condition shall not prevent the message from being sent.
1535
1536        * Other errors shall prevent the sending of the message.
1537
1538       When in command mode:
1539
1540        * Default.
1541
1542       The following sections are informative.
1543

APPLICATION USAGE

1545       Delivery of messages to remote systems requires the existence of commu‐
1546       nication paths to such systems. These need not exist.
1547
1548       Input  lines  are limited to {LINE_MAX} bytes, but mailers between sys‐
1549       tems may impose more severe line-length restrictions.  This  volume  of
1550       IEEE Std 1003.1-2001  does  not place any restrictions on the length of
1551       messages handled by mailx, and for delivery of local messages the  only
1552       limitations  should  be the normal problems of available disk space for
1553       the target mail file.  When  sending  messages  to  external  machines,
1554       applications  are  advised  to limit messages to less than 100000 bytes
1555       because some mail gateways impose message-length restrictions.
1556
1557       The format of the system mailbox is intentionally unspecified. Not  all
1558       systems implement system mailboxes as flat files, particularly with the
1559       advent of multimedia mail messages. Some system mailboxes may be multi‐
1560       ple  files,  others  records  in a database. The internal format of the
1561       messages themselves is specified with the historical format  from  Ver‐
1562       sion 7,  but only after the messages have been saved in some file other
1563       than the system mailbox. This was done so that many historical applica‐
1564       tions expecting text-file mailboxes are not broken.
1565
1566       Some  new  formats for messages can be expected in the future, probably
1567       including binary data, bit maps, and  various  multimedia  objects.  As
1568       described  here,  mailx  is not prohibited from handling such messages,
1569       but it must store them as text files  in  secondary  mailboxes  (unless
1570       some  extension,  such as a variable or command line option, is used to
1571       change the stored format). Its method of doing  so  is  implementation-
1572       defined  and might include translating the data into text file-compati‐
1573       ble or readable form or omitting certain portions of the  message  from
1574       the stored output.
1575
1576       The discard and ignore commands are not inverses of the retain command.
1577       The retain command discards all header-fields except  those  explicitly
1578       retained.  The  discard  command  keeps  all header-fields except those
1579       explicitly discarded. If headers exist on  the  retained  header  list,
1580       discard and ignore commands are ignored.
1581

EXAMPLES

1583       None.
1584

RATIONALE

1586       The standard developers felt strongly that a method for applications to
1587       send messages to specific users was necessary. The obvious example is a
1588       batch  utility,  running  non-interactively, that wishes to communicate
1589       errors or results to a user. However, the actual format, delivery mech‐
1590       anism,  and  method of reading the message are clearly beyond the scope
1591       of this volume of IEEE Std 1003.1-2001.
1592
1593       The intent of this command is to provide a simple,  portable  interface
1594       for sending messages non-interactively. It merely defines a "front-end"
1595       to the historical mail system. It  is  suggested  that  implementations
1596       explicitly denote the sender and recipient in the body of the delivered
1597       message. Further specification of formats for either the message  enve‐
1598       lope  or the message itself were deliberately not made, as the industry
1599       is in the midst of changing from the current standards to a more inter‐
1600       nationalized  standard  and  it is probably incorrect, at this time, to
1601       require either one.
1602
1603       Implementations are encouraged to conform to the various delivery mech‐
1604       anisms  described  in  the  CCITT  X.400 standards or to the equivalent
1605       Internet standards, described in Internet  Request  for  Comment  (RFC)
1606       documents RFC 819, RFC 822, RFC 920, RFC 921, and RFC 1123.
1607
1608       Many historical systems modified each body line that started with From
1609       by prefixing the 'F' with '>' . It is unnecessary, but allowed,  to  do
1610       that  when the string does not follow a blank line because it cannot be
1611       confused with the next header.
1612
1613       The edit and visual commands merely edit the specified  messages  in  a
1614       temporary  file.  They  do not modify the contents of those messages in
1615       the mailbox; such a capability could be added as an extension, such  as
1616       by using different command names.
1617
1618       The restriction on a subject line being {LINE_MAX}-10 bytes is based on
1619       the historical format that consumes 10  bytes  for  Subject:   and  the
1620       trailing   <newline>.  Many  historical  mailers  that  a  message  may
1621       encounter on other systems are not able to handle lines that long, how‐
1622       ever.
1623
1624       Like  the  utilities  logger  and  lp, mailx admittedly is difficult to
1625       test. This was not deemed  sufficient  justification  to  exclude  this
1626       utility  from  this volume of IEEE Std 1003.1-2001. It is also arguable
1627       that it is, in fact, testable, but that the tests  themselves  are  not
1628       portable.
1629
1630       When  mailx  is being used by an application that wishes to receive the
1631       results as if none of the User Portability  Utilities  option  features
1632       were supported, the DEAD environment variable must be set to /dev/null.
1633       Otherwise, it may be subject to the file creations described  in  mailx
1634       ASYNCHRONOUS  EVENTS.  Similarly, if the MAILRC environment variable is
1635       not set to /dev/null, historical versions of mailx and Mail  read  ini‐
1636       tialization  commands  from  a file before processing begins. Since the
1637       initialization that a user specifies could alter the contents  of  mes‐
1638       sages  an  application  is  trying  to send, such applications must set
1639       MAILRC to /dev/null.
1640
1641       The description of LC_TIME uses "may affect"  because  many  historical
1642       implementations  do  not or cannot manipulate the date and time strings
1643       in the incoming mail headers. Some headers found in  incoming  mail  do
1644       not have enough information to determine the timezone in which the mail
1645       originated, and, therefore, mailx cannot  convert  the  date  and  time
1646       strings  into  the  internal  form that then is parsed by routines like
1647       strftime() that can take LC_TIME settings into  account.  Changing  all
1648       these times to a user-specified format is allowed, but not required.
1649
1650       The paginator selected when PAGER is null or unset is partially unspec‐
1651       ified to allow the System V historical practice  of  using  pg  as  the
1652       default.  Bypassing  the pagination function, such as by declaring that
1653       cat is the paginator, would not meet with the intended meaning of  this
1654       description.  However,  any  "portable  user"  would  have to set PAGER
1655       explicitly to get his or her preferred paginator on  all  systems.  The
1656       paginator choice was made partially unspecified, unlike the VISUAL edi‐
1657       tor choice (mandated to be vi) because most historical pagers follow  a
1658       common theme of user input, whereas editors differ dramatically.
1659
1660       Options  to  specify addresses as cc (carbon copy) or bcc (blind carbon
1661       copy) were considered to be format details and were omitted.
1662
1663       A zero exit status implies that all messages were sent, but it gives no
1664       assurances that any of them were actually delivered. The reliability of
1665       the delivery mechanism is unspecified and is an  appropriate  marketing
1666       distinction between systems.
1667
1668       In  order  to  conform to the Utility Syntax Guidelines, a solution was
1669       required to the optional file option-argument to -f. By making file  an
1670       operand,  the  guidelines are satisfied and users remain portable. How‐
1671       ever, it does force implementations to support usage such as:
1672
1673
1674              mailx -fin mymail.box
1675
1676       The no name method of unsetting variables is not present in all histor‐
1677       ical  systems, but it is in System V and provides a logical set of com‐
1678       mands corresponding to the format of the display of  options  from  the
1679       mailx set command without arguments.
1680
1681       The  ask  and asksub variables are the names selected by BSD and System
1682       V, respectively, for the same feature. They are synonyms in this volume
1683       of IEEE Std 1003.1-2001.
1684
1685       The  mailx  echo  command was not documented in the BSD version and has
1686       been omitted here because it is not obviously  useful  for  interactive
1687       users.
1688
1689       The  default  prompt  on  the System V mailx is a question mark, on BSD
1690       Mail an ampersand. Since this volume of IEEE Std 1003.1-2001 chose  the
1691       mailx name, it kept the System V default, assuming that BSD users would
1692       not have difficulty with this  minor  incompatibility  (that  they  can
1693       override).
1694
1695       The  meanings  of r and R are reversed between System V mailx and SunOS
1696       Mail. Once again, since this volume of IEEE Std 1003.1-2001  chose  the
1697       mailx  name, it kept the System V default, but allows the SunOS user to
1698       achieve the desired results using flipr, an internal variable in System
1699       V mailx, although it has not been documented in the SVID.
1700
1701       The  indentprefix variable, the retain and unalias commands, and the ~F
1702       and ~M command escapes were adopted from 4.3 BSD Mail.
1703
1704       The version command was not included because  no  sufficiently  general
1705       specification  of  the  version information could be devised that would
1706       still be useful to a portable user. This command name should be used by
1707       suppliers  who wish to provide version information about the mailx com‐
1708       mand.
1709
1710       The "implementation-specific (unspecified) system start-up  file"  his‐
1711       torically  has  been  named  /etc/mailx.rc,  but this specific name and
1712       location are not required.
1713
1714       The intent of the wording for the next command is that if  any  command
1715       has already displayed the current message it should display a following
1716       message, but, otherwise, it should display the  current  message.  Con‐
1717       sider the command sequence:
1718
1719
1720              next 3
1721              delete 3
1722              next
1723
1724       where  the  autoprint  option was not set. The normative text specifies
1725       that the second next command should display  a  message  following  the
1726       third  message,  because  even  though the current message has not been
1727       displayed since it was set by the delete command, it has been displayed
1728       since  the  current  message  was anything other than message number 3.
1729       This does not always match historical practice in some implementations,
1730       where  the  command  file address followed by next (or the default com‐
1731       mand) would skip the message for which the user had searched.
1732

FUTURE DIRECTIONS

1734       None.
1735

SEE ALSO

1737       Shell Command Language , ed , ls , more , vi
1738
1740       Portions of this text are reprinted and reproduced in  electronic  form
1741       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
1742       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
1743       Specifications  Issue  6,  Copyright  (C) 2001-2003 by the Institute of
1744       Electrical and Electronics Engineers, Inc and The Open  Group.  In  the
1745       event of any discrepancy between this version and the original IEEE and
1746       The Open Group Standard, the original IEEE and The Open Group  Standard
1747       is  the  referee document. The original Standard can be obtained online
1748       at http://www.opengroup.org/unix/online.html .
1749
1750
1751
1752IEEE/The Open Group                  2003                             MAILX(P)
Impressum