1MAILX(1P) POSIX Programmer's Manual MAILX(1P)
2
3
4
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
12 mailx - process messages
13
15 Send Mode
16 mailx [-s subject] address...
17
18 Receive Mode
19 mailx -e
20
21
22
23
24 mailx [-HiNn][-F][-u user]
25
26
27
28 mailx -f[-HiNn][-F][file]
29
30
32 The mailx utility provides a message sending and receiving facility.
33 It has two major modes, selected by the options used: Send Mode and
34 Receive Mode.
35
36 On systems that do not support the User Portability Utilities option,
37 an application using mailx shall have the ability to send messages in
38 an unspecified manner (Send Mode). Unless the first character of one or
39 more lines is tilde ( '~' ), all characters in the input message shall
40 appear in the delivered message, but additional characters may be
41 inserted in the message before it is retrieved.
42
43 On systems supporting the User Portability Utilities option, mail-
44 receiving capabilities and other interactive features, Receive Mode,
45 described below, also shall be enabled.
46
47 Send Mode
48 Send Mode can be used by applications or users to send messages from
49 the text in standard input.
50
51 Receive Mode
52 Receive Mode is more oriented towards interactive users. Mail can be
53 read and sent in this interactive mode.
54
55 When reading mail, mailx provides commands to facilitate saving, delet‐
56 ing, and responding to messages. When sending mail, mailx allows edit‐
57 ing, reviewing, and other modification of the message as it is entered.
58
59 Incoming mail shall be stored in one or more unspecified locations for
60 each user, collectively called the system mailbox for that user. When
61 mailx is invoked in Receive Mode, the system mailbox shall be the
62 default place to find new mail. As messages are read, they shall be
63 marked to be moved to a secondary file for storage, unless specific
64 action is taken. This secondary file is called the mbox and is normally
65 located in the directory referred to by the HOME environment variable
66 (see MBOX in the ENVIRONMENT VARIABLES section for a description of
67 this file). Messages shall remain in this file until explicitly
68 removed. When the -f option is used to read mail messages from sec‐
69 ondary files, messages shall be retained in those files unless specifi‐
70 cally removed. All three of these locations-system mailbox, mbox, and
71 secondary file-are referred to in this section as simply "mailboxes",
72 unless more specific identification is required.
73
75 The mailx utility shall conform to the Base Definitions volume of
76 IEEE Std 1003.1-2001, Section 12.2, Utility Syntax Guidelines.
77
78 The following options shall be supported. (Only the -s subject option
79 shall be required on all systems. The other options are required only
80 on systems supporting the User Portability Utilities option.)
81
82 -e Test for the presence of mail in the system mailbox. The mailx
83 utility shall write nothing and exit with a successful return
84 code if there is mail to read.
85
86 -f Read messages from the file named by the file operand instead of
87 the system mailbox. (See also folder.) If no file operand is
88 specified, read messages from mbox instead of the system mail‐
89 box.
90
91 -F Record the message in a file named after the first recipient.
92 The name is the login-name portion of the address found first on
93 the To: line in the mail header. Overrides the record variable,
94 if set (see Internal Variables in mailx .)
95
96 -H Write a header summary only.
97
98 -i Ignore interrupts. (See also ignore.)
99
100 -n Do not initialize from the system default start-up file. See the
101 EXTENDED DESCRIPTION section.
102
103 -N Do not write an initial header summary.
104
105 -s subject
106 Set the Subject header field to subject. All characters in the
107 subject string shall appear in the delivered message. The
108 results are unspecified if subject is longer than {LINE_MAX} -
109 10 bytes or contains a <newline>.
110
111 -u user
112 Read the system mailbox of the login name user. This shall only
113 be successful if the invoking user has the appropriate privi‐
114 leges to read the system mailbox of that user.
115
116
118 The following operands shall be supported:
119
120 address
121 Addressee of message. When -n is specified and no user start-up
122 files are accessed (see the EXTENDED DESCRIPTION section), the
123 user or application shall ensure this is an address to pass to
124 the mail delivery system. Any system or user start-up files may
125 enable aliases (see alias under Commands in mailx ) that may
126 modify the form of address before it is passed to the mail
127 delivery system.
128
129 file A pathname of a file to be read instead of the system mailbox
130 when -f is specified. The meaning of the file option-argument
131 shall be affected by the contents of the folder internal vari‐
132 able; see Internal Variables in mailx .
133
134
136 When mailx is invoked in Send Mode (the first synopsis line), standard
137 input shall be the message to be delivered to the specified addresses.
138 When in Receive Mode, user commands shall be accepted from stdin. If
139 the User Portability Utilities option is not supported, standard input
140 lines beginning with a tilde ( '~' ) character produce unspecified
141 results.
142
143 If the User Portability Utilities option is supported, then in both
144 Send and Receive Modes, standard input lines beginning with the escape
145 character (usually tilde ( '~' )) shall affect processing as described
146 in Command Escapes in mailx .
147
149 When mailx is used as described by this volume of IEEE Std 1003.1-2001,
150 the file option-argument (see the -f option) and the mbox shall be text
151 files containing mail messages, formatted as described in the OUTPUT
152 FILES section. The nature of the system mailbox is unspecified; it need
153 not be a file.
154
156 The following environment variables shall affect the execution of
157 mailx:
158
159 DEAD Determine the pathname of the file in which to save partial mes‐
160 sages in case of interrupts or delivery errors. The default
161 shall be dead.letter in the directory named by the HOME vari‐
162 able. The behavior of mailx in saving partial messages is
163 unspecified if the User Portability Utilities option is not sup‐
164 ported and DEAD is not defined with the value /dev/null.
165
166 EDITOR Determine the name of a utility to invoke when the edit (see
167 Commands in mailx ) or ~e (see Command Escapes in mailx ) com‐
168 mand is used. The default editor is unspecified. On XSI-con‐
169 formant systems it is ed. The effects of this variable are
170 unspecified if the User Portability Utilities option is not sup‐
171 ported.
172
173 HOME Determine the pathname of the user's home directory.
174
175 LANG Provide a default value for the internationalization variables
176 that are unset or null. (See the Base Definitions volume of
177 IEEE Std 1003.1-2001, Section 8.2, Internationalization Vari‐
178 ables for the precedence of internationalization variables used
179 to determine the values of locale categories.)
180
181 LC_ALL If set to a non-empty string value, override the values of all
182 the other internationalization variables.
183
184 LC_CTYPE
185 Determine the locale for the interpretation of sequences of
186 bytes of text data as characters (for example, single-byte as
187 opposed to multi-byte characters in arguments and input files)
188 and the handling of case-insensitive address and header-field
189 comparisons.
190
191 LC_TIME
192 Determine the format and contents of the date and time strings
193 written by mailx.
194
195 LC_MESSAGES
196 Determine the locale that should be used to affect the format
197 and contents of diagnostic messages written to standard error
198 and informative messages written to standard output.
199
200 LISTER Determine a string representing the command for writing the con‐
201 tents of the folder directory to standard output when the fold‐
202 ers command is given (see folders in Commands in mailx ). Any
203 string acceptable as a command_string operand to the sh -c com‐
204 mand shall be valid. If this variable is null or not set, the
205 output command shall be ls. The effects of this variable are
206 unspecified if the User Portability Utilities option is not sup‐
207 ported.
208
209 MAILRC Determine the pathname of the start-up file. The default shall
210 be .mailrc in the directory referred to by the HOME environment
211 variable. The behavior of mailx is unspecified if the User
212 Portability Utilities option is not supported and MAILRC is not
213 defined with the value /dev/null.
214
215 MBOX Determine a pathname of the file to save messages from the sys‐
216 tem mailbox that have been read. The exit command shall override
217 this function, as shall saving the message explicitly in another
218 file. The default shall be mbox in the directory named by the
219 HOME variable. The effects of this variable are unspecified if
220 the User Portability Utilities option is not supported.
221
222 NLSPATH
223 Determine the location of message catalogs for the processing of
224 LC_MESSAGES .
225
226 PAGER Determine a string representing an output filtering or pagina‐
227 tion command for writing the output to the terminal. Any string
228 acceptable as a command_string operand to the sh -c command
229 shall be valid. When standard output is a terminal device, the
230 message output shall be piped through the command if the mailx
231 internal variable crt is set to a value less the number of lines
232 in the message; see Internal Variables in mailx . If the PAGER
233 variable is null or not set, the paginator shall be either more
234 or another paginator utility documented in the system documenta‐
235 tion. The effects of this variable are unspecified if the User
236 Portability Utilities option is not supported.
237
238 SHELL Determine the name of a preferred command interpreter. The
239 default shall be sh. The effects of this variable are unspeci‐
240 fied if the User Portability Utilities option is not supported.
241
242 TERM If the internal variable screen is not specified, determine the
243 name of the terminal type to indicate in an unspecified manner
244 the number of lines in a screenful of headers. If TERM is not
245 set or is set to null, an unspecified default terminal type
246 shall be used and the value of a screenful is unspecified. The
247 effects of this variable are unspecified if the User Portability
248 Utilities option is not supported.
249
250 TZ This variable may determine the timezone used to calculate date
251 and time strings written by mailx. If TZ is unset or null, an
252 unspecified default timezone shall be used.
253
254 VISUAL Determine a pathname of a utility to invoke when the visual com‐
255 mand (see Commands in mailx ) or ~v command-escape (see Command
256 Escapes in mailx ) is used. If this variable is null or not set,
257 the full-screen editor shall be vi. The effects of this vari‐
258 able are unspecified if the User Portability Utilities option is
259 not supported.
260
261
263 When mailx is in Send Mode and standard input is not a terminal, it
264 shall take the standard action for all signals.
265
266 In Receive Mode, or in Send Mode when standard input is a terminal, if
267 a SIGINT signal is received:
268
269 1. If in command mode, the current command, if there is one, shall be
270 aborted, and a command-mode prompt shall be written.
271
272 2. If in input mode:
273
274 a. If ignore is set, mailx shall write "@\n", discard the current
275 input line, and continue processing, bypassing the message-
276 abort mechanism described in item 2b.
277
278 b. If the interrupt was received while sending mail, either when
279 in Receive Mode or in Send Mode, a message shall be written,
280 and another subsequent interrupt, with no other intervening
281 characters typed, shall be required to abort the mail message.
282 If in Receive Mode and another interrupt is received, a com‐
283 mand-mode prompt shall be written. If in Send Mode and another
284 interrupt is received, mailx shall terminate with a non-zero
285 status.
286
287 In both cases listed in item b, if the message is not empty:
288
289 i. If save is enabled and the file named by DEAD can be
290 created, the message shall be written to the file named
291 by DEAD. If the file exists, the message shall be
292 written to replace the contents of the file.
293
294 ii. If save is not enabled, or the file named by DEAD can‐
295 not be created, the message shall not be saved.
296
297 The mailx utility shall take the standard action for all other signals.
298
300 In command and input modes, all output, including prompts and messages,
301 shall be written to standard output.
302
304 The standard error shall be used only for diagnostic messages.
305
307 Various mailx commands and command escapes can create or add to files,
308 including the mbox, the dead-letter file, and secondary mailboxes. When
309 mailx is used as described in this volume of IEEE Std 1003.1-2001,
310 these files shall be text files, formatted as follows: line beginning
311 with From<space>
312 [one or more header-lines; see Commands in mailx ]
313 empty line
314 [zero or more body lines
315 empty line]
316 [line beginning with From<space>...]
317
318 where each message begins with the From <space> line shown, preceded by
319 the beginning of the file or an empty line. (The From <space> line is
320 considered to be part of the message header, but not one of the header-
321 lines referred to in Commands in mailx ; thus, it shall not be affected
322 by the discard, ignore, or retain commands.) The formats of the remain‐
323 der of the From <space> line and any additional header lines are
324 unspecified, except that none shall be empty. The format of a message
325 body line is also unspecified, except that no line following an empty
326 line shall start with From <space>; mailx shall modify any such user-
327 entered message body lines (following an empty line and beginning with
328 From <space>) by adding one or more characters to precede the 'F' ; it
329 may add these characters to From <space> lines that are not preceded by
330 an empty line.
331
332 When a message from the system mailbox or entered by the user is not a
333 text file, it is implementation-defined how such a message is stored in
334 files written by mailx.
335
337 The entire EXTENDED DESCRIPTION section shall apply only to implementa‐
338 tions supporting the User Portability Utilities option.
339
340 The mailx utility cannot guarantee support for all character encodings
341 in all circumstances. For example, inter-system mail may be restricted
342 to 7-bit data by the underlying network, 8-bit data need not be porta‐
343 ble to non-internationalized systems, and so on. Under these circum‐
344 stances, it is recommended that only characters defined in the
345 ISO/IEC 646:1991 standard International Reference Version (equivalent
346 to ASCII) 7-bit range of characters be used.
347
348 When mailx is invoked using one of the Receive Mode synopsis forms, it
349 shall write a page of header-summary lines (if -N was not specified and
350 there are messages, see below), followed by a prompt indicating that
351 mailx can accept regular commands (see Commands in mailx ); this is
352 termed command mode. The page of header-summary lines shall contain the
353 first new message if there are new messages, or the first unread mes‐
354 sage if there are unread messages, or the first message. When mailx is
355 invoked using the Send Mode synopsis and standard input is a terminal,
356 if no subject is specified on the command line and the asksub variable
357 is set, a prompt for the subject shall be written. At this point, mailx
358 shall be in input mode. This input mode shall also be entered when
359 using one of the Receive Mode synopsis forms and a reply or new message
360 is composed using the reply, Reply, followup, Followup, or mail com‐
361 mands and standard input is a terminal. When the message is typed and
362 the end of the message is encountered, the message shall be passed to
363 the mail delivery software. Commands can be entered by beginning a line
364 with the escape character (by default, tilde ( '~' )) followed by a
365 single command letter and optional arguments. See Commands in mailx
366 for a summary of these commands. It is unspecified what effect these
367 commands will have if standard input is not a terminal when a message
368 is entered using either the Send Mode synopsis, or the Read Mode com‐
369 mands reply, Reply, followup, Followup, or mail.
370
371 Note: For notational convenience, this section uses the default escape
372 character, tilde, in all references and examples.
373
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 parameters
377 that can be set and cleared via the mailx set and unset commands.
378
379 Regular commands are of the form:
380
381
382 [command] [msglist] [argument ...]
383
384 If no command is specified in command mode, next shall be assumed. In
385 input mode, commands shall be recognized by the escape character, and
386 lines not treated as commands shall be taken as input for the message.
387
388 In command mode, each message shall be assigned a sequential number,
389 starting with 1.
390
391 All messages have a state that shall affect how they are displayed in
392 the header summary and how they are retained or deleted upon termina‐
393 tion of mailx. There is at any time the notion of a current message,
394 which shall be marked by a '>' at the beginning of a line in the header
395 summary. When mailx is invoked using one of the Receive Mode synopsis
396 forms, the current message shall be the first new message, if there is
397 a new message, or the first unread message if there is an unread mes‐
398 sage, or the first message if there are any messages, or unspecified if
399 there are no messages in the mailbox. Each command that takes an
400 optional list of messages (msglist) or an optional single message (mes‐
401 sage) on which to operate shall leave the current message set to the
402 highest-numbered message of the messages specified, unless the command
403 deletes messages, in which case the current message shall be set to the
404 first undeleted message (that is, a message not in the deleted state)
405 after the highest-numbered message deleted by the command, if one
406 exists, or the first undeleted message before the highest-numbered mes‐
407 sage deleted by the command, if one exists, or to an unspecified value
408 if there are no remaining undeleted messages. All messages shall be in
409 one of the following states:
410
411 new The message is present in the system mailbox and has not been
412 viewed by the user or moved to any other state. Messages in
413 state new when mailx quits shall be retained in the system mail‐
414 box.
415
416 unread The message has been present in the system mailbox for more than
417 one invocation of mailx and has not been viewed by the user or
418 moved to any other state. Messages in state unread when mailx
419 quits shall be retained in the system mailbox.
420
421 read The message has been processed by one of the following commands:
422 ~f, ~m, ~F, ~M, copy, mbox, next, pipe, print, Print, top, type,
423 Type, undelete. The delete, dp, and dt commands may also cause
424 the next message to be marked as read, depending on the value of
425 the autoprint variable. Messages that are in the system mailbox
426 and in state read when mailx quits shall be saved in the mbox,
427 unless the internal variable hold was set. Messages that are in
428 the mbox or in a secondary mailbox and in state read when mailx
429 quits shall be retained in their current location.
430
431 deleted
432 The message has been processed by one of the following commands:
433 delete, dp, dt. Messages in state deleted when mailx quits shall
434 be deleted. Deleted messages shall be ignored until mailx quits
435 or changes mailboxes or they are specified to the undelete com‐
436 mand; for example, the message specification / string shall only
437 search the subject lines of messages that have not yet been
438 deleted, unless the command operating on the list of messages is
439 undelete. No deleted message or deleted message header shall be
440 displayed by any mailx command other than undelete.
441
442 preserved
443 The message has been processed by a preserve command. When mailx
444 quits, the message shall be retained in its current location.
445
446 saved The message has been processed by one of the following commands:
447 save or write. If the current mailbox is the system mailbox, and
448 the internal variable keepsave is set, messages in the state
449 saved shall be saved to the file designated by the MBOX variable
450 (see the ENVIRONMENT VARIABLES section). If the current mailbox
451 is the system mailbox, messages in the state saved shall be
452 deleted from the current mailbox, when the quit or file command
453 is used to exit the current mailbox.
454
455
456 The header-summary line for each message shall indicate the state of
457 the message.
458
459 Many commands take an optional list of messages ( msglist) on which to
460 operate, which defaults to the current message. A msglist is a list of
461 message specifications separated by <blank>s, which can 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
483 All messages from address; any address as shown in a header sum‐
484 mary shall be matchable in this form.
485
486 /string
487 All messages with string in the subject line (case ignored).
488
489 :c All messages of type c, where c shall be one of:
490
491 d
492 Deleted messages.
493
494 n
495 New messages.
496
497 o
498 Old messages (any not in state read or new).
499
500 r
501 Read messages.
502
503 u
504 Unread messages.
505
506
507
508 Other commands take an optional message ( message) on which to operate,
509 which defaults to the current message. All of the forms allowed for
510 msglist are also allowed for message, but if more than one message is
511 specified, only the first shall be operated on.
512
513 Other arguments are usually arbitrary strings whose usage depends on
514 the command involved.
515
516 Start-Up in mailx
517 At start-up time, mailx shall take the following steps in sequence:
518
519 1. Establish all variables at their stated default values.
520
521 2. Process command line options, overriding corresponding default val‐
522 ues.
523
524 3. Import any of the DEAD, EDITOR, MBOX, LISTER , PAGER, SHELL,
525 or VISUAL variables that are present in the environment, overriding
526 the corresponding default values.
527
528 4. Read mailx commands from an unspecified system start-up file,
529 unless the -n option is given, to initialize any internal mailx
530 variables and aliases.
531
532 5. Process the start-up file of mailx commands named in the user
533 MAILRC variable.
534
535 Most regular mailx commands are valid inside start-up files, the most
536 common use being to set up initial display options and alias lists. The
537 following commands shall be invalid in the start-up file: !, edit,
538 hold, mail, preserve, reply, Reply, shell, visual, Copy, followup, and
539 Followup. Any errors in the start-up file shall either cause mailx to
540 terminate with a diagnostic message and a non-zero status or to con‐
541 tinue after writing a diagnostic message, ignoring the remainder of the
542 lines in the start-up file.
543
544 A blank line in a start-up file shall be ignored.
545
546 Internal Variables in mailx
547 The following variables are internal mailx variables. Each internal
548 variable can be set via the mailx set command at any time. The unset
549 and set no name commands can be used to erase variables.
550
551 In the following list, variables shown as:
552
553
554 variable
555
556 represent Boolean values. Variables shown as:
557
558
559 variable=value
560
561 shall be assigned string or numeric values. For string values, the
562 rules in Commands in mailx concerning filenames and quoting shall also
563 apply.
564
565 The defaults specified here may be changed by the implementation-
566 defined system start-up file unless the user specifies the -n option.
567
568 allnet All network names whose login name components match shall be
569 treated as identical. This shall cause the msglist message spec‐
570 ifications to behave similarly. The default shall be noallnet.
571 See also the alternates command and the metoo variable.
572
573 append Append messages to the end of the mbox file upon termination
574 instead of placing them at the beginning. The default shall be
575 noappend. This variable shall not affect the save command when
576 saving to mbox.
577
578 ask, asksub
579 Prompt for a subject line on outgoing mail if one is not speci‐
580 fied on the command line with the -s option. The ask and asksub
581 forms are synonyms; the system shall refer to asksub and
582 noasksub in its messages, but shall accept ask and noask as user
583 input to mean asksub and noasksub. It shall not be possible to
584 set both ask and noasksub, or noask and asksub. The default
585 shall be asksub, but no prompting shall be done if standard
586 input is not a terminal.
587
588 askbcc Prompt for the blind copy list. The default shall be noaskbcc.
589
590 askcc Prompt for the copy list. The default shall be noaskcc.
591
592 autoprint
593 Enable automatic writing of messages after delete and undelete
594 commands. The default shall be noautoprint.
595
596 bang Enable the special-case treatment of exclamation marks ( '!' )
597 in escape command lines; see the escape command and Command
598 Escapes in mailx . The default shall be nobang, disabling the
599 expansion of '!' in the command argument to the ~! command and
600 the ~<! command escape.
601
602 cmd=command
603
604 Set the default command to be invoked by the pipe command. The
605 default shall be nocmd.
606
607 crt=number
608 Pipe messages having more than number lines through the command
609 specified by the value of the PAGER variable. The default shall
610 be nocrt. If it is set to null, the value used is implementa‐
611 tion-defined.
612
613 debug Enable verbose diagnostics for debugging. Messages are not
614 delivered. The default shall be nodebug.
615
616 dot When dot is set, a period on a line by itself during message
617 input from a terminal shall also signify end-of-file (in addi‐
618 tion to normal end-of-file). The default shall be nodot. If
619 ignoreeof is set (see below), a setting of nodot shall be
620 ignored and the period is the only method to terminate input
621 mode.
622
623 escape=c
624 Set the command escape character to be the character 'c' . By
625 default, the command escape character shall be tilde. If escape
626 is unset, tilde shall be used; if it is set to null, command
627 escaping shall be disabled.
628
629 flipr Reverse the meanings of the R and r commands. The default shall
630 be noflipr.
631
632 folder=directory
633
634 The default directory for saving mail files. User-specified
635 filenames beginning with a plus sign ( '+' ) shall be expanded
636 by preceding the filename with this directory name to obtain the
637 real pathname. If directory does not start with a slash ( '/' ),
638 the contents of HOME shall be prefixed to it. The default shall
639 be nofolder. If folder is unset or set to null, user-specified
640 filenames beginning with '+' shall refer to files in the current
641 directory that begin with the literal '+' character. See also
642 outfolder below. The folder value need not affect the process‐
643 ing of the files named in MBOX and DEAD.
644
645 header Enable writing of the header summary when entering mailx in
646 Receive Mode. The default shall be header.
647
648 hold Preserve all messages that are read in the system mailbox
649 instead of putting them in the mbox save file. The default shall
650 be nohold.
651
652 ignore Ignore interrupts while entering messages. The default shall be
653 noignore.
654
655 ignoreeof
656 Ignore normal end-of-file during message input. Input can be
657 terminated only by entering a period ( '.' ) on a line by itself
658 or by the ~. command escape. The default shall be noignoreeof.
659 See also dot above.
660
661 indentprefix=string
662
663 A string that shall be added as a prefix to each line that is
664 inserted into the message by the ~m command escape. This vari‐
665 able shall default to one <tab>.
666
667 keep When a system mailbox, secondary mailbox, or mbox is empty,
668 truncate it to zero length instead of removing it. The default
669 shall be nokeep.
670
671 keepsave
672 Keep the messages that have been saved from the system mailbox
673 into other files in the file designated by the variable MBOX ,
674 instead of deleting them. The default shall be nokeepsave.
675
676 metoo Suppress the deletion of the login name of the user from the
677 recipient list when replying to a message or sending to a group.
678 The default shall be nometoo.
679
680 onehop When responding to a message that was originally sent to several
681 recipients, the other recipient addresses are normally forced to
682 be relative to the originating author's machine for the
683 response. This flag disables alteration of the recipients'
684 addresses, improving efficiency in a network where all machines
685 can send directly to all other machines (that is, one hop away).
686 The default shall be noonehop.
687
688 outfolder
689 Cause the files used to record outgoing messages to be located
690 in the directory specified by the folder variable unless the
691 pathname is absolute. The default shall be nooutfolder. See the
692 record variable.
693
694 page Insert a <form-feed> after each message sent through the pipe
695 created by the pipe command. The default shall be nopage.
696
697 prompt=string
698
699 Set the command-mode prompt to string. If string is null or if
700 noprompt is set, no prompting shall occur. The default shall be
701 to prompt with the string "? " .
702
703 quiet Refrain from writing the opening message and version when enter‐
704 ing mailx. The default shall be noquiet.
705
706 record=file
707 Record all outgoing mail in the file with the pathname file.
708 The default shall be norecord. See also outfolder above.
709
710 save Enable saving of messages in the dead-letter file on interrupt
711 or delivery error. See the variable DEAD for the location of the
712 dead-letter file. The default shall be save.
713
714 screen=number
715
716 Set the number of lines in a screenful of headers for the head‐
717 ers and z commands. If screen is not specified, a value based on
718 the terminal type identified by the TERM environment variable,
719 the window size, the baud rate, or some combination of these
720 shall be used.
721
722 sendwait
723 Wait for the background mailer to finish before returning. The
724 default shall be nosendwait.
725
726 showto When the sender of the message was the user who is invoking
727 mailx, write the information from the To: line instead of the
728 From: line in the header summary. The default shall be noshowto.
729
730 sign=string
731 Set the variable inserted into the text of a message when the ~a
732 command escape is given. The default shall be nosign. The char‐
733 acter sequences '\t' and '\n' shall be recognized in the vari‐
734 able as <tab>s and <newline>s, respectively. (See also ~i in
735 Command Escapes in mailx .)
736
737 Sign=string
738 Set the variable inserted into the text of a message when the ~A
739 command escape is given. The default shall be noSign. The char‐
740 acter sequences '\t' and '\n' shall be recognized in the vari‐
741 able as <tab>s and <newline>s, respectively.
742
743 toplines=number
744
745 Set the number of lines of the message to write with the top
746 command. The default shall be 5.
747
748
749 Commands in mailx
750 The following mailx commands shall be provided. In the following list,
751 header refers to lines from the message header, as shown in the OUTPUT
752 FILES section. Header-line refers to lines within the header that begin
753 with one or more non-white-space characters, immediately followed by a
754 colon and white space and continuing until the next line beginning with
755 a non-white-space character or an empty line. Header-field refers to
756 the portion of a header line prior to the first colon in that line.
757
758 For each of the commands listed below, the command can be entered as
759 the abbreviation (those characters in the Synopsis command word preced‐
760 ing the '[' ), the full command (all characters shown for the command
761 word, omitting the '[' and ']' ), or any truncation of the full command
762 down to the abbreviation. For example, the exit command (shown as
763 ex[it] in the Synopsis) can be entered as ex, exi, or exit.
764
765 The arguments to commands can be quoted, using the following methods:
766
767 * An argument can be enclosed between paired double-quotes ( "" ) or
768 single-quotes ( '' ); any white space, shell word expansion, or
769 backslash characters within the quotes shall be treated literally as
770 part of the argument. A double-quote shall be treated literally
771 within single-quotes and vice versa. These special properties of
772 the quote marks shall occur only when they are paired at the begin‐
773 ning and end of the argument.
774
775 * A backslash outside of the enclosing quotes shall be discarded and
776 the following character treated literally as part of the argument.
777
778 * An unquoted backslash at the end of a command line shall be dis‐
779 carded and the next line shall continue the command.
780
781 Filenames, where expected, shall be subjected to the following trans‐
782 formations, in sequence:
783
784 * If the filename begins with an unquoted plus sign, and the folder
785 variable is defined (see the folder variable), the plus sign shall
786 be replaced by the value of the folder variable followed by a slash.
787 If the folder variable is unset or is set to null, the filename
788 shall be unchanged.
789
790 * Shell word expansions shall be applied to the filename (see Word
791 Expansions ). If more than a single pathname results from this
792 expansion and the command is expecting one file, the effects are
793 unspecified.
794
795 Declare Aliases
796 Synopsis:
797
798
799 a[lias] [alias [address...]]g[roup] [alias [address...]]
800
801
802 Add the given addresses to the alias specified by alias. The names
803 shall be substituted when alias is used as a recipient address speci‐
804 fied by the user in an outgoing message (that is, other recipients
805 addressed indirectly through the reply command shall not be substituted
806 in this manner). Mail address alias substitution shall apply only when
807 the alias string is used as a full address; for example, when hlj is an
808 alias, hlj@posix.com does not trigger the alias substitution. If no
809 arguments are given, write a listing of the current aliases to standard
810 output. If only an alias argument is given, write a listing of the
811 specified alias to standard output. These listings need not reflect the
812 same order of addresses that were entered.
813
814 Declare Alternatives
815 Synopsis:
816
817
818 alt[ernates] name...
819
820
821 (See also the metoo command.) Declare a list of alternative names for
822 the user's login. When responding to a message, these names shall be
823 removed from the list of recipients for the response. The comparison
824 of names shall be in a case-insensitive manner. With no arguments,
825 alternates shall write the current list of alternative names.
826
827 Change Current Directory
828 Synopsis:
829
830
831 cd [directory]ch[dir] [directory]
832
833
834 Change directory. If directory is not specified, the contents of HOME
835 shall be used.
836
837 Copy Messages
838 Synopsis:
839
840
841 c[opy] [file]c[opy] [msglist] fileC[opy] [msglist]
842
843
844 Copy messages to the file named by the pathname file without marking
845 the messages as saved. Otherwise, it shall be equivalent to the save
846 command.
847
848 In the capitalized form, save the specified messages in a file whose
849 name is derived from the author of the message to be saved, without
850 marking the messages as saved. Otherwise, it shall be equivalent to the
851 Save command.
852
853 Delete Messages
854 Synopsis:
855
856
857 d[elete] [msglist]
858
859
860 Mark messages for deletion from the mailbox. The deletions shall not
861 occur until mailx quits (see the quit command) or changes mailboxes
862 (see the folder command). If autoprint is set and there are messages
863 remaining after the delete command, the current message shall be writ‐
864 ten as described for the print command (see the print command); other‐
865 wise, the mailx prompt shall be written.
866
867 Discard Header Fields
868 Synopsis:
869
870
871 di[scard] [header-field...]ig[nore] [header-field...]
872
873
874 Suppress the specified header fields when writing messages. Specified
875 header-fields shall be added to the list of suppressed header fields.
876 Examples of header fields to ignore are status and cc. The fields shall
877 be included when the message is saved. The Print and Type commands
878 shall override this command. The comparison of header fields shall be
879 in a case-insensitive manner. If no arguments are specified, write a
880 list of the currently suppressed header fields to standard output; the
881 listing need not reflect the same order of header fields that were
882 entered.
883
884 If both retain and discard commands are given, discard commands shall
885 be ignored.
886
887 Delete Messages and Display
888 Synopsis:
889
890
891 dp [msglist]dt [msglist]
892
893
894 Delete the specified messages as described for the delete command,
895 except that the autoprint variable shall have no effect, and the cur‐
896 rent message shall be written only if it was set to a message after the
897 last message deleted by the command. Otherwise, an informational mes‐
898 sage to the effect that there are no further messages in the mailbox
899 shall be written, followed by the mailx prompt.
900
901 Echo a String
902 Synopsis:
903
904
905 ec[ho] string ...
906
907
908 Echo the given strings, equivalent to the shell echo utility.
909
910 Edit Messages
911 Synopsis:
912
913
914 e[dit] [msglist]
915
916
917 Edit the given messages. The messages shall be placed in a temporary
918 file and the utility named by the EDITOR variable is invoked to edit
919 each file in sequence. The default EDITOR is unspecified.
920
921 The edit command does not modify the contents of those messages in the
922 mailbox.
923
924 Exit
925 Synopsis:
926
927
928 ex[it]x[it]
929
930
931 Exit from mailx without changing the mailbox. No messages shall be
932 saved in the mbox (see also quit).
933
934 Change Folder
935 Synopsis:
936
937
938 fi[le] [file]fold[er] [file]
939
940
941 Quit (see the quit command) from the current file of messages and read
942 in the file named by the pathname file. If no argument is given, the
943 name and status of the current mailbox shall be written.
944
945 Several unquoted special characters shall be recognized when used as
946 file names, with the following substitutions:
947
948 % The system mailbox for the invoking user.
949
950 %user The system mailbox for user.
951
952 # The previous file.
953
954 & The current mbox.
955
956 +file The named file in the folder directory. (See the folder vari‐
957 able.)
958
959
960 The default file shall be the current mailbox.
961
962 Display List of Folders
963 Synopsis:
964
965
966 folders
967
968
969 Write the names of the files in the directory set by the folder vari‐
970 able. The command specified by the LISTER environment variable shall be
971 used (see the ENVIRONMENT VARIABLES section).
972
973 Follow Up Specified Messages
974 Synopsis:
975
976
977 fo[llowup] [message]F[ollowup] [msglist]
978
979
980 In the lowercase form, respond to a message, recording the response in
981 a file whose name is derived from the author of the message. See also
982 the save and copy commands and outfolder.
983
984 In the capitalized form, respond to the first message in the msglist,
985 sending the message to the author of each message in the msglist. The
986 subject line shall be taken from the first message and the response
987 shall be recorded in a file whose name is derived from the author of
988 the first message. See also the Save and Copy commands and outfolder.
989
990 Both forms shall override the record variable, if set.
991
992 Display Header Summary for Specified Messages
993 Synopsis:
994
995
996 f[rom] [msglist]
997
998
999 Write the header summary for the specified messages.
1000
1001 Display Header Summary
1002 Synopsis:
1003
1004
1005 h[eaders] [message]
1006
1007
1008 Write the page of headers that includes the message specified. If the
1009 message argument is not specified, the current message shall not
1010 change. However, if the message argument is specified, the current mes‐
1011 sage shall become the message that appears at the top of the page of
1012 headers that includes the message specified. The screen variable sets
1013 the number of headers per page. See also the z command.
1014
1015 Help
1016 Synopsis:
1017
1018
1019 hel[p]?
1020
1021
1022 Write a summary of commands.
1023
1024 Hold Messages
1025 Synopsis:
1026
1027
1028 ho[ld] [msglist]pre[serve] [msglist]
1029
1030
1031 Mark the messages in msglist to be retained in the mailbox when mailx
1032 terminates. This shall override any commands that might previously have
1033 marked the messages to be deleted. During the current invocation of
1034 mailx, only the delete, dp, or dt commands shall remove the preserve
1035 marking of a message.
1036
1037 Execute Commands Conditionally
1038 Synopsis:
1039
1040
1041 i[f] s|r
1042 mail-commands
1043 el[se]
1044 mail-commands
1045 en[dif]
1046
1047
1048 Execute commands conditionally, where if s executes the following mail-
1049 commands, up to an else or endif, if the program is in Send Mode, and
1050 if r shall cause the mail-commands to be executed only in Receive Mode.
1051
1052 List Available Commands
1053 Synopsis:
1054
1055
1056 l[ist]
1057
1058
1059 Write a list of all commands available. No explanation shall be given.
1060
1061 Mail a Message
1062 Synopsis:
1063
1064
1065 m[ail] address...
1066
1067
1068 Mail a message to the specified addresses or aliases.
1069
1070 Direct Messages to mbox
1071 Synopsis:
1072
1073
1074 mb[ox] [msglist]
1075
1076
1077 Arrange for the given messages to end up in the mbox save file when
1078 mailx terminates normally. See MBOX. See also the exit and quit com‐
1079 mands.
1080
1081 Process Next Specified Message
1082 Synopsis:
1083
1084
1085 n[ext] [message]
1086
1087
1088 If the current message has not been written (for example, by the print
1089 command) since mailx started or since any other message was the current
1090 message, behave as if the print command was entered. Otherwise, if
1091 there is an undeleted message after the current message, make it the
1092 current message and behave as if the print command was entered. Other‐
1093 wise, an informational message to the effect that there are no further
1094 messages in the mailbox shall be written, followed by the mailx prompt.
1095
1096 Pipe Message
1097 Synopsis:
1098
1099
1100 pi[pe] [[msglist] command]| [[msglist] command]
1101
1102
1103 Pipe the messages through the given command by invoking the command
1104 interpreter specified by SHELL with two arguments: -c and command. (See
1105 also sh -c.) The application shall ensure that the command is given as
1106 a single argument. Quoting, described previously, can be used to accom‐
1107 plish this. If no arguments are given, the current message shall be
1108 piped through the command specified by the value of the cmd variable.
1109 If the page variable is set, a <form-feed> shall be inserted after each
1110 message.
1111
1112 Display Message with Headers
1113 Synopsis:
1114
1115
1116 P[rint] [msglist]T[ype] [msglist]
1117
1118
1119 Write the specified messages, including all header lines, to standard
1120 output. Override suppression of lines by the discard, ignore, and
1121 retain commands. If crt is set, the messages longer than the number of
1122 lines specified by the crt variable shall be paged through the command
1123 specified by the PAGER environment variable.
1124
1125 Display Message
1126 Synopsis:
1127
1128
1129 p[rint] [msglist]t[ype] [msglist]
1130
1131
1132 Write the specified messages to standard output. If crt is set, the
1133 messages longer than the number of lines specified by the crt variable
1134 shall be paged through the command specified by the PAGER environment
1135 variable.
1136
1137 Quit
1138 Synopsis:
1139
1140
1141 q[uit]
1142 end-of-file
1143
1144
1145 Terminate mailx, storing messages that were read in mbox (if the cur‐
1146 rent mailbox is the system mailbox and unless hold is set), deleting
1147 messages that have been explicitly saved (unless keepsave is set), dis‐
1148 carding messages that have been deleted, and saving all remaining mes‐
1149 sages in the mailbox.
1150
1151 Reply to a Message List
1152 Synopsis:
1153
1154
1155 R[eply] [msglist]R[espond] [msglist]
1156
1157
1158 Mail a reply message to the sender of each message in the msglist. The
1159 subject line shall be formed by concatenating Re: <space> (unless it
1160 already begins with that string) and the subject from the first mes‐
1161 sage. If record is set to a filename, the response shall be saved at
1162 the end of that file.
1163
1164 See also the flipr variable.
1165
1166 Reply to a Message
1167 Synopsis:
1168
1169
1170 r[eply] [message]r[espond] [message]
1171
1172
1173 Mail a reply message to all recipients included in the header of the
1174 message. The subject line shall be formed by concatenating Re: <space>
1175 (unless it already begins with that string) and the subject from the
1176 message. If record is set to a filename, the response shall be saved at
1177 the end of that file.
1178
1179 See also the flipr variable.
1180
1181 Retain Header Fields
1182 Synopsis:
1183
1184
1185 ret[ain] [header-field...]
1186
1187
1188 Retain the specified header fields when writing messages. This command
1189 shall override all discard and ignore commands. The comparison of
1190 header fields shall be in a case-insensitive manner. If no arguments
1191 are specified, write a list of the currently retained header fields to
1192 standard output; the listing need not reflect the same order of header
1193 fields that were entered.
1194
1195 Save Messages
1196 Synopsis:
1197
1198
1199 s[ave] [file]s[ave] [msglist] fileS[ave] [msglist]
1200
1201
1202 Save the specified messages in the file named by the pathname file, or
1203 the mbox if the file argument is omitted. The file shall be created if
1204 it does not exist; otherwise, the messages shall be appended to the
1205 file. The message shall be put in the state saved, and shall behave as
1206 specified in the description of the saved state when the current mail‐
1207 box is exited by the quit or file command.
1208
1209 In the capitalized form, save the specified messages in a file whose
1210 name is derived from the author of the first message. The name of the
1211 file shall be taken to be the author's name with all network addressing
1212 stripped off. See also the Copy, followup, and Followup commands and
1213 outfolder variable.
1214
1215 Set Variables
1216 Synopsis:
1217
1218
1219 se[t] [name[=[string]] ...] [name=number ...] [noname ...]
1220
1221
1222 Define one or more variables called name. The variable can be given a
1223 null, string, or numeric value. Quoting and backslash escapes can occur
1224 anywhere in string, as described previously, as if the string portion
1225 of the argument were the entire argument. The forms name and name=
1226 shall be equivalent to name="" for variables that take string values.
1227 The set command without arguments shall write a list of all defined
1228 variables and their values. The no name form shall be equivalent to
1229 unset name.
1230
1231 Invoke a Shell
1232 Synopsis:
1233
1234
1235 sh[ell]
1236
1237
1238 Invoke an interactive command interpreter (see also SHELL ).
1239
1240 Display Message Size
1241 Synopsis:
1242
1243
1244 si[ze] [msglist]
1245
1246
1247 Write the size in bytes of each of the specified messages.
1248
1249 Read mailx Commands From a File
1250 Synopsis:
1251
1252
1253 so[urce] file
1254
1255
1256 Read and execute commands from the file named by the pathname file and
1257 return to command mode.
1258
1259 Display Beginning of Messages
1260 Synopsis:
1261
1262
1263 to[p] [msglist]
1264
1265
1266 Write the top few lines of each of the specified messages. If the
1267 toplines variable is set, it is taken as the number of lines to write.
1268 The default shall be 5.
1269
1270 Touch Messages
1271 Synopsis:
1272
1273
1274 tou[ch] [msglist]
1275
1276
1277 Touch the specified messages. If any message in msglist is not specifi‐
1278 cally deleted nor saved in a file, it shall be placed in the mbox upon
1279 normal termination. See exit and quit.
1280
1281 Delete Aliases
1282 Synopsis:
1283
1284
1285 una[lias] [alias]...
1286
1287
1288 Delete the specified alias names. If a specified alias does not exist,
1289 the results are unspecified.
1290
1291 Undelete Messages
1292 Synopsis:
1293
1294
1295 u[ndelete] [msglist]
1296
1297
1298 Change the state of the specified messages from deleted to read. If
1299 autoprint is set, the last message of those restored shall be written.
1300 If msglist is not specified, the message shall be selected as follows:
1301
1302 * If there are any deleted messages that follow the current message,
1303 the first of these shall be chosen.
1304
1305 * Otherwise, the last deleted message that also precedes the current
1306 message shall be chosen.
1307
1308 Unset Variables
1309 Synopsis:
1310
1311
1312 uns[et] name...
1313
1314
1315 Cause the specified variables to be erased.
1316
1317 Edit Message with Full-Screen Editor
1318 Synopsis:
1319
1320
1321 v[isual] [msglist]
1322
1323
1324 Edit the given messages with a screen editor. Each message shall be
1325 placed in a temporary file, and the utility named by the VISUAL vari‐
1326 able shall be invoked to edit each file in sequence. The default edi‐
1327 tor shall be vi.
1328
1329 The visual command does not modify the contents of those messages in
1330 the mailbox.
1331
1332 Write Messages to a File
1333 Synopsis:
1334
1335
1336 w[rite] [msglist] file
1337
1338
1339 Write the given messages to the file specified by the pathname file,
1340 minus the message header. Otherwise, it shall be equivalent to the save
1341 command.
1342
1343 Scroll Header Display
1344 Synopsis:
1345
1346
1347 z[+|-]
1348
1349
1350 Scroll the header display forward (if '+' is specified or if no option
1351 is specified) or backward (if '-' is specified) one screenful. The num‐
1352 ber of headers written shall be set by the screen variable.
1353
1354 Invoke Shell Command
1355 Synopsis:
1356
1357
1358 !command
1359
1360
1361 Invoke the command interpreter specified by SHELL with two arguments:
1362 -c and command. (See also sh -c.) If the bang variable is set, each
1363 unescaped occurrence of '!' in command shall be replaced with the com‐
1364 mand executed by the previous ! command or ~! command escape.
1365
1366 Null Command
1367 Synopsis:
1368
1369
1370 # comment
1371
1372
1373 This null command (comment) shall be ignored by mailx.
1374
1375 Display Current Message Number
1376 Synopsis:
1377
1378
1379 =
1380
1381
1382 Write the current message number.
1383
1384 Command Escapes in mailx
1385 The following commands can be entered only from input mode, by begin‐
1386 ning a line with the escape character (by default, tilde ( '~' )). See
1387 the escape variable description for changing this special character.
1388 The format for the commands shall be:
1389
1390
1391 <escape-character><command-char><separator>[<arguments>]
1392
1393 where the <separator> can be zero or more <blank>s.
1394
1395 In the following descriptions, the application shall ensure that the
1396 argument command (but not mailx-command) is a shell command string. Any
1397 string acceptable to the command interpreter specified by the SHELL
1398 variable when it is invoked as SHELL -c command_string shall be valid.
1399 The command can be presented as multiple arguments (that is, quoting is
1400 not required).
1401
1402 Command escapes that are listed with msglist or mailx-command arguments
1403 are invalid in Send Mode and produce unspecified results.
1404
1405 ~! command
1406 Invoke the command interpreter specified by SHELL with two argu‐
1407 ments: -c and command; and then return to input mode. If the
1408 bang variable is set, each unescaped occurrence of '!' in com‐
1409 mand shall be replaced with the command executed by the previous
1410 ! command or ~! command escape.
1411
1412 ~. Simulate end-of-file (terminate message input).
1413
1414 ~: mailx-command, ~_ mailx-command
1415
1416 Perform the command-level request.
1417
1418 ~? Write a summary of command escapes.
1419
1420 ~A This shall be equivalent to ~i Sign.
1421
1422 ~a This shall be equivalent to ~i sign.
1423
1424 ~b name...
1425 Add the names to the blind carbon copy ( Bcc) list.
1426
1427 ~c name...
1428 Add the names to the carbon copy ( Cc) list.
1429
1430 ~d Read in the dead-letter file. See DEAD for a description of this
1431 file.
1432
1433 ~e Invoke the editor, as specified by the EDITOR environment vari‐
1434 able, on the partial message.
1435
1436 ~f [msglist]
1437 Forward the specified messages. The specified messages shall be
1438 inserted into the current message without alteration. This com‐
1439 mand escape also shall insert message headers into the message
1440 with field selection affected by the discard, ignore, and retain
1441 commands.
1442
1443 ~F [msglist]
1444 This shall be the equivalent of the ~f command escape, except
1445 that all headers shall be included in the message, regardless of
1446 previous discard, ignore, and retain commands.
1447
1448 ~h If standard input is a terminal, prompt for a Subject line and
1449 the To, Cc, and Bcc lists. Other implementation-defined headers
1450 may also be presented for editing. If the field is written with
1451 an initial value, it can be edited as if it had just been typed.
1452
1453 ~i string
1454 Insert the value of the named variable, followed by a <newline>,
1455 into the text of the message. If the string is unset or null,
1456 the message shall not be changed.
1457
1458 ~m [msglist]
1459 Insert the specified messages into the message, prefixing non-
1460 empty lines with the string in the indentprefix variable. This
1461 command escape also shall insert message headers into the mes‐
1462 sage, with field selection affected by the discard, ignore, and
1463 retain commands.
1464
1465 ~M [msglist]
1466 This shall be the equivalent of the ~m command escape, except
1467 that all headers shall be included in the message, regardless of
1468 previous discard, ignore, and retain commands.
1469
1470 ~p Write the message being entered. If the message is longer than
1471 crt lines (see Internal Variables in mailx ), the output shall
1472 be paginated as described for the PAGER variable.
1473
1474 ~q Quit (see the quit command) from input mode by simulating an
1475 interrupt. If the body of the message is not empty, the partial
1476 message shall be saved in the dead-letter file. See DEAD for a
1477 description of this file.
1478
1479 ~r file, ~<
1480 file, ~r !command, ~< !command
1481
1482 Read in the file specified by the pathname file. If the argument
1483 begins with an exclamation mark ( '!' ), the rest of the string
1484 shall be taken as an arbitrary system command; the command
1485 interpreter specified by SHELL shall be invoked with two argu‐
1486 ments: -c and command. The standard output of command shall be
1487 inserted into the message.
1488
1489 ~s string
1490 Set the subject line to string.
1491
1492 ~t name...
1493 Add the given names to the To list.
1494
1495 ~v Invoke the full-screen editor, as specified by the VISUAL envi‐
1496 ronment variable, on the partial message.
1497
1498 ~w file
1499 Write the partial message, without the header, onto the file
1500 named by the pathname file. The file shall be created or the
1501 message shall be appended to it if the file exists.
1502
1503 ~x Exit as with ~q, except the message shall not be saved in the
1504 dead-letter file.
1505
1506 ~| command
1507 Pipe the body of the message through the given command by invok‐
1508 ing the command interpreter specified by SHELL with two argu‐
1509 ments: -c and command. If the command returns a successful exit
1510 status, the standard output of the command shall replace the
1511 message. Otherwise, the message shall remain unchanged. If the
1512 command fails, an error message giving the exit status shall be
1513 written.
1514
1515
1517 When the -e option is specified, the following exit values are
1518 returned:
1519
1520 0 Mail was found.
1521
1522 >0 Mail was not found or an error occurred.
1523
1524
1525 Otherwise, the following exit values are returned:
1526
1527 0 Successful completion; note that this status implies that all
1528 messages were sent, but it gives no assurances that any of them
1529 were actually delivered.
1530
1531 >0 An error occurred.
1532
1533
1535 When in input mode (Receive Mode) or Send Mode:
1536
1537 * If an error is encountered processing a command escape (see Command
1538 Escapes in mailx ), a diagnostic message shall be written to stan‐
1539 dard error, and the message being composed may be modified, but this
1540 condition shall not prevent the message from being sent.
1541
1542 * Other errors shall prevent the sending of the message.
1543
1544 When in command mode:
1545
1546 * Default.
1547
1548 The following sections are informative.
1549
1551 Delivery of messages to remote systems requires the existence of commu‐
1552 nication paths to such systems. These need not exist.
1553
1554 Input lines are limited to {LINE_MAX} bytes, but mailers between sys‐
1555 tems may impose more severe line-length restrictions. This volume of
1556 IEEE Std 1003.1-2001 does not place any restrictions on the length of
1557 messages handled by mailx, and for delivery of local messages the only
1558 limitations should be the normal problems of available disk space for
1559 the target mail file. When sending messages to external machines,
1560 applications are advised to limit messages to less than 100000 bytes
1561 because some mail gateways impose message-length restrictions.
1562
1563 The format of the system mailbox is intentionally unspecified. Not all
1564 systems implement system mailboxes as flat files, particularly with the
1565 advent of multimedia mail messages. Some system mailboxes may be multi‐
1566 ple files, others records in a database. The internal format of the
1567 messages themselves is specified with the historical format from Ver‐
1568 sion 7, but only after the messages have been saved in some file other
1569 than the system mailbox. This was done so that many historical applica‐
1570 tions expecting text-file mailboxes are not broken.
1571
1572 Some new formats for messages can be expected in the future, probably
1573 including binary data, bit maps, and various multimedia objects. As
1574 described here, mailx is not prohibited from handling such messages,
1575 but it must store them as text files in secondary mailboxes (unless
1576 some extension, such as a variable or command line option, is used to
1577 change the stored format). Its method of doing so is implementation-
1578 defined and might include translating the data into text file-compati‐
1579 ble or readable form or omitting certain portions of the message from
1580 the stored output.
1581
1582 The discard and ignore commands are not inverses of the retain command.
1583 The retain command discards all header-fields except those explicitly
1584 retained. The discard command keeps all header-fields except those
1585 explicitly discarded. If headers exist on the retained header list,
1586 discard and ignore commands are ignored.
1587
1589 None.
1590
1592 The standard developers felt strongly that a method for applications to
1593 send messages to specific users was necessary. The obvious example is a
1594 batch utility, running non-interactively, that wishes to communicate
1595 errors or results to a user. However, the actual format, delivery mech‐
1596 anism, and method of reading the message are clearly beyond the scope
1597 of this volume of IEEE Std 1003.1-2001.
1598
1599 The intent of this command is to provide a simple, portable interface
1600 for sending messages non-interactively. It merely defines a "front-end"
1601 to the historical mail system. It is suggested that implementations
1602 explicitly denote the sender and recipient in the body of the delivered
1603 message. Further specification of formats for either the message enve‐
1604 lope or the message itself were deliberately not made, as the industry
1605 is in the midst of changing from the current standards to a more inter‐
1606 nationalized standard and it is probably incorrect, at this time, to
1607 require either one.
1608
1609 Implementations are encouraged to conform to the various delivery mech‐
1610 anisms described in the CCITT X.400 standards or to the equivalent
1611 Internet standards, described in Internet Request for Comment (RFC)
1612 documents RFC 819, RFC 822, RFC 920, RFC 921, and RFC 1123.
1613
1614 Many historical systems modified each body line that started with From
1615 by prefixing the 'F' with '>' . It is unnecessary, but allowed, to do
1616 that when the string does not follow a blank line because it cannot be
1617 confused with the next header.
1618
1619 The edit and visual commands merely edit the specified messages in a
1620 temporary file. They do not modify the contents of those messages in
1621 the mailbox; such a capability could be added as an extension, such as
1622 by using different command names.
1623
1624 The restriction on a subject line being {LINE_MAX}-10 bytes is based on
1625 the historical format that consumes 10 bytes for Subject: and the
1626 trailing <newline>. Many historical mailers that a message may
1627 encounter on other systems are not able to handle lines that long, how‐
1628 ever.
1629
1630 Like the utilities logger and lp, mailx admittedly is difficult to
1631 test. This was not deemed sufficient justification to exclude this
1632 utility from this volume of IEEE Std 1003.1-2001. It is also arguable
1633 that it is, in fact, testable, but that the tests themselves are not
1634 portable.
1635
1636 When mailx is being used by an application that wishes to receive the
1637 results as if none of the User Portability Utilities option features
1638 were supported, the DEAD environment variable must be set to /dev/null.
1639 Otherwise, it may be subject to the file creations described in mailx
1640 ASYNCHRONOUS EVENTS. Similarly, if the MAILRC environment variable is
1641 not set to /dev/null, historical versions of mailx and Mail read ini‐
1642 tialization commands from a file before processing begins. Since the
1643 initialization that a user specifies could alter the contents of mes‐
1644 sages an application is trying to send, such applications must set
1645 MAILRC to /dev/null.
1646
1647 The description of LC_TIME uses "may affect" because many historical
1648 implementations do not or cannot manipulate the date and time strings
1649 in the incoming mail headers. Some headers found in incoming mail do
1650 not have enough information to determine the timezone in which the mail
1651 originated, and, therefore, mailx cannot convert the date and time
1652 strings into the internal form that then is parsed by routines like
1653 strftime() that can take LC_TIME settings into account. Changing all
1654 these times to a user-specified format is allowed, but not required.
1655
1656 The paginator selected when PAGER is null or unset is partially unspec‐
1657 ified to allow the System V historical practice of using pg as the
1658 default. Bypassing the pagination function, such as by declaring that
1659 cat is the paginator, would not meet with the intended meaning of this
1660 description. However, any "portable user" would have to set PAGER
1661 explicitly to get his or her preferred paginator on all systems. The
1662 paginator choice was made partially unspecified, unlike the VISUAL edi‐
1663 tor choice (mandated to be vi) because most historical pagers follow a
1664 common theme of user input, whereas editors differ dramatically.
1665
1666 Options to specify addresses as cc (carbon copy) or bcc (blind carbon
1667 copy) were considered to be format details and were omitted.
1668
1669 A zero exit status implies that all messages were sent, but it gives no
1670 assurances that any of them were actually delivered. The reliability of
1671 the delivery mechanism is unspecified and is an appropriate marketing
1672 distinction between systems.
1673
1674 In order to conform to the Utility Syntax Guidelines, a solution was
1675 required to the optional file option-argument to -f. By making file an
1676 operand, the guidelines are satisfied and users remain portable. How‐
1677 ever, it does force implementations to support usage such as:
1678
1679
1680 mailx -fin mymail.box
1681
1682 The no name method of unsetting variables is not present in all histor‐
1683 ical systems, but it is in System V and provides a logical set of com‐
1684 mands corresponding to the format of the display of options from the
1685 mailx set command without arguments.
1686
1687 The ask and asksub variables are the names selected by BSD and System
1688 V, respectively, for the same feature. They are synonyms in this volume
1689 of IEEE Std 1003.1-2001.
1690
1691 The mailx echo command was not documented in the BSD version and has
1692 been omitted here because it is not obviously useful for interactive
1693 users.
1694
1695 The default prompt on the System V mailx is a question mark, on BSD
1696 Mail an ampersand. Since this volume of IEEE Std 1003.1-2001 chose the
1697 mailx name, it kept the System V default, assuming that BSD users would
1698 not have difficulty with this minor incompatibility (that they can
1699 override).
1700
1701 The meanings of r and R are reversed between System V mailx and SunOS
1702 Mail. Once again, since this volume of IEEE Std 1003.1-2001 chose the
1703 mailx name, it kept the System V default, but allows the SunOS user to
1704 achieve the desired results using flipr, an internal variable in System
1705 V mailx, although it has not been documented in the SVID.
1706
1707 The indentprefix variable, the retain and unalias commands, and the ~F
1708 and ~M command escapes were adopted from 4.3 BSD Mail.
1709
1710 The version command was not included because no sufficiently general
1711 specification of the version information could be devised that would
1712 still be useful to a portable user. This command name should be used by
1713 suppliers who wish to provide version information about the mailx com‐
1714 mand.
1715
1716 The "implementation-specific (unspecified) system start-up file" his‐
1717 torically has been named /etc/mailx.rc, but this specific name and
1718 location are not required.
1719
1720 The intent of the wording for the next command is that if any command
1721 has already displayed the current message it should display a following
1722 message, but, otherwise, it should display the current message. Con‐
1723 sider the command sequence:
1724
1725
1726 next 3
1727 delete 3
1728 next
1729
1730 where the autoprint option was not set. The normative text specifies
1731 that the second next command should display a message following the
1732 third message, because even though the current message has not been
1733 displayed since it was set by the delete command, it has been displayed
1734 since the current message was anything other than message number 3.
1735 This does not always match historical practice in some implementations,
1736 where the command file address followed by next (or the default com‐
1737 mand) would skip the message for which the user had searched.
1738
1740 None.
1741
1743 Shell Command Language, ed, ls, more, vi
1744
1746 Portions of this text are reprinted and reproduced in electronic form
1747 from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
1748 -- Portable Operating System Interface (POSIX), The Open Group Base
1749 Specifications Issue 6, Copyright (C) 2001-2003 by the Institute of
1750 Electrical and Electronics Engineers, Inc and The Open Group. In the
1751 event of any discrepancy between this version and the original IEEE and
1752 The Open Group Standard, the original IEEE and The Open Group Standard
1753 is the referee document. The original Standard can be obtained online
1754 at http://www.opengroup.org/unix/online.html .
1755
1756
1757
1758IEEE/The Open Group 2003 MAILX(1P)