Debian Codegraph @

upstream/debian-unstable/man1/bsd-mailx.1

raw
1 .\" $OpenBSD: mail.1,v 1.83 2022/03/31 17:27:25 naddy Exp $
2 .\"
3 .\" Copyright (c) 1980, 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
17 .\"
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" SUCH DAMAGE.
29 .\"
30 .\" @(#)mail.1 8.8 (Berkeley) 4/28/95
31 .\"
32 .Dd $Mdocdate: March 31 2022 $
33 .Dt MAIL 1
34 .Os
35 .Sh NAME
36 .Nm mail ,
37 .Nm mailx ,
38 .Nm Mail
39 .Nd send and receive mail
40 .Sh SYNOPSIS
41 .Nm mail
42 .Bk -words
43 .Op Fl dEIinv
44 .Op Fl a Ar header
45 .Op Fl b Ar bcc-addr
46 .Op Fl c Ar cc-addr
47 .Op Fl r Ar from-addr
48 .Op Fl s Ar subject
49 .Op Fl -
50 .Ar to-addr ...
51 .Ek
52 .Nm mail
53 .Op Fl dEIiNnv
54 .Fl f
55 .Op Ar file
56 .Nm mail
57 .Op Fl dEIiNnv
58 .Op Fl u Ar user
59 .Sh DESCRIPTION
60 .Nm mail
61 is an intelligent mail processing system which has
62 a command syntax reminiscent of
63 .Xr ed 1
64 with lines replaced by messages.
65 .Pp
66 The options are as follows:
67 .Bl -tag -width Ds
68 .It Fl a
69 Specify additional header fields on the command line such as "X-Loop:
70 foo@bar" etc.
71 It can be also used to override MIME headers
72 .Nm mail
73 adds by default to each outgoing mail, see
74 .Sx Character sets and MIME
75 below.
76 You have to use quotes if the string contains spaces.
77 This argument may be specified more than once, the headers will then
78 be concatenated.
79 .It Fl b Ar bcc-addr
80 Send blind carbon copies to
81 .Ar bcc-addr .
82 .It Fl c Ar cc-addr
83 Send carbon copies to
84 list
85 of users.
86 .Ar cc-addr
87 should be a comma separated list of names.
88 .It Fl d
89 Causes
90 .Nm mail
91 to output all sorts of information useful for debugging
92 .Nm mail .
93 .It Fl E
94 Don't send messages with an empty body.
95 .It Fl f
96 Use an alternate mailbox.
97 Defaults to the user's
98 .Ar mbox
99 if no
100 .Ar file
101 is specified.
102 When quit,
103 .Nm mail
104 writes undeleted messages back to this
105 .Ar file .
106 .It Fl I
107 Forces
108 .Nm mail
109 to run in interactive mode, even when input is not a terminal.
110 In particular, the special
111 .Ic ~
112 command character, used when sending mail, is only available interactively.
113 .It Fl i
114 Ignore tty interrupt signals.
115 This is
116 particularly useful when using
117 .Nm mail
118 on noisy phone lines.
119 .It Fl N
120 Inhibits initial display of message headers
121 when reading mail or editing a mail folder.
122 .It Fl n
123 Inhibits reading
124 .Pa /etc/mail.rc
125 upon startup.
126 .It Fl r Ar from-addr
127 Use
128 .Ar from-addr
129 as the from address in the message and envelope.
130 Overrides any
131 .Ar from
132 options in the startup files.
133 .It Fl s Ar subject
134 Specify subject on command line
135 (only the first argument after the
136 .Fl s
137 flag is used as a subject; be careful to quote subjects
138 containing spaces).
139 .It Fl u Ar user
140 Equivalent to:
141 .Pp
142 .Dl $ mail -f /var/mail/user
143 .Pp
144 except that locking is done.
145 .It Fl v
146 Verbose mode.
147 The details of
148 delivery are displayed on the user's terminal.
149 .It Fl -
150 End of options. Any further argument is treated as a direct receipient address.
151 .Pp
152 .Em Note:
153 For security reasons the
154 .Fl -
155 separator is strongly recommended for scripts that need to send mails
156 to addresses obtained from untrusted sources (such as web forms).
157 .El
158 .Ss Startup actions
159 At startup time,
160 .Nm mail
161 will execute commands in the system command file,
162 .Pa /etc/mail.rc ,
163 unless explicitly told not to by using the
164 .Fl n
165 option.
166 Next, the commands in the user's personal command file
167 .Pa ~/.mailrc
168 are executed.
169 .Nm mail
170 then examines its command line options to determine whether the user
171 requested a new message to be sent or existing messages in a mailbox
172 to be examined.
173 .Ss Sending mail
174 To send a message to one or more people,
175 .Nm mail
176 can be invoked with arguments which are the names of people to
177 whom the mail will be sent.
178 You are then expected to type in
179 your message, followed
180 by a control-D
181 .Pq Sq ^D
182 at the beginning of a line.
183 The section below,
184 .Sx Replying to or originating mail ,
185 describes some features of
186 .Nm mail
187 available to help you compose your letter.
188 .Ss Reading mail
189 In normal usage,
190 .Nm mail
191 is given no arguments and checks your mail out of the
192 post office, then
193 prints out a one line header of each message found.
194 The current message is initially set to the first message (numbered 1)
195 and can be printed using the
196 .Ic print
197 command (which can be abbreviated
198 .Ic p ) .
199 Moving among the messages is much like moving between lines in
200 .Xr ed 1 ;
201 you may use
202 .Ic +
203 and
204 .Ic -
205 to shift forwards and backwards, or simply enter a message number to move
206 directly.
207 .Ss Disposing of mail
208 After examining a message, you can
209 .Ic delete
210 .Pq Ic d
211 or
212 .Ic reply
213 .Pq Ic r
214 to it.
215 Deletion causes the
216 .Nm mail
217 program to forget about the message.
218 This is not irreversible; the message can be
219 .Ic undeleted
220 .Pq Ic u
221 by giving its number, or the
222 .Nm mail
223 session can be aborted by giving the
224 .Ic exit
225 .Pq Ic x
226 command.
227 Deleted messages, however, will usually disappear, never to be seen again.
228 .Ss Specifying messages
229 Commands such as
230 .Ic print
231 and
232 .Ic delete
233 can be given a list of message numbers as arguments to apply
234 to a number of messages at once.
235 Thus
236 .Ic delete 1 2
237 deletes messages 1 and 2, while
238 .Ic delete 1\-5
239 deletes messages 1 through 5.
240 .Pp
241 Messages may also be selected using one of the following categories:
242 .Pp
243 .Bl -tag -width Ds -offset indent -compact
244 .It *
245 all messages
246 .It $
247 last message
248 .It :d
249 deleted messages
250 .It :n
251 new messages
252 .It :o
253 old messages
254 .It :r
255 read messages
256 .It :u
257 unread messages
258 .El
259 .Pp
260 Thus the command
261 .Ic top ,
262 which prints the first few lines of a message,
263 could be used in
264 .Ic top *
265 to print the first few lines of all messages.
266 .Ss Replying to or originating mail
267 You can use the
268 .Ic reply
269 command to
270 set up a response to a message, sending it back to the
271 person who it was from.
272 Text you then type in, up to an end-of-file,
273 defines the contents of the message.
274 While you are composing a message,
275 .Nm mail
276 treats lines beginning with the tilde
277 .Pq Sq ~
278 character specially.
279 For instance, typing
280 .Ic ~m
281 (alone on a line) will place a copy
282 of the current message into the response, right shifting it by a single
283 tab-stop (see the
284 .Va indentprefix
285 variable, below).
286 Other escapes will set up subject fields, add and delete recipients
287 to the message, and allow you to escape to an editor to revise the
288 message or to a shell to run some commands.
289 (These options
290 are given in the summary below.)
291 .Ss Ending a mail processing session
292 You can end a
293 .Nm mail
294 session with the
295 .Ic quit
296 .Pq Ic q
297 command.
298 Messages which have been examined go to your
299 .Ar mbox
300 file unless they have been deleted, in which case they are discarded.
301 Unexamined messages go back to the post office (see the
302 .Fl f
303 option above).
304 .Ss Personal and system wide distribution lists
305 It is also possible to create personal distribution lists so that,
306 for instance, you can send mail to
307 .Dq Li cohorts
308 and have it go
309 to a group of people.
310 Such lists can be defined by placing a line like
311 .Pp
312 .Dl alias cohorts bill ozalp jkf mark kridle@ucbcory
313 .Pp
314 in the file
315 .Pa .mailrc
316 in your home directory.
317 The current list of such aliases can be displayed with the
318 .Ic alias
319 command in
320 .Nm mail .
321 System wide distribution lists can be created by editing
322 .Pa /etc/aliases ,
323 (see
324 .Xr aliases 5 ) ;
325 these are kept in a different syntax.
326 In mail you send, personal aliases will be expanded in mail sent
327 to others so that they will be able to
328 .Ic reply
329 to the recipients.
330 System wide aliases
331 are not expanded when the mail is sent,
332 but any reply returned to the machine will have the system wide
333 alias expanded as all mail goes through an MTA.
334 .Ss Recipient address specifications
335 Recipient addresses (any of the
336 .Dq To ,
337 .Dq Cc
338 or
339 .Dq Bcc
340 header fields) are subject to expansion when the
341 .Ic expandaddr
342 option is set.
343 .Pp
344 An address may be expanded as follows:
345 .Bl -bullet -width Ds
346 .It
347 An address that starts with a pipe
348 .Pq Ql |
349 character is treated as a command to run.
350 The command immediately following the
351 .Ql |
352 is executed with the message as its standard input.
353 .It
354 An address that starts with a
355 .Ql +
356 character is treated as a folder.
357 .It
358 An address that contains a
359 .Ql /
360 character but no
361 .Ql \&! ,
362 .Ql % ,
363 or
364 .Ql @
365 characters is also treated as a folder.
366 .It
367 If none of the above apply, the recipient is treated as
368 a local or network mail address.
369 .El
370 .Pp
371 If the
372 .Ic expandaddr
373 option is not set (the default), no expansion is performed and
374 the recipient is treated as a local or network mail address.
375 .Ss Character sets and MIME
376 Generally
377 .Nm mail
378 does not handle neither different character sets nor any other MIME
379 feature. Especially it does not perform any any conversions between
380 character sets while displaying or sending mails.
381 .Pp
382 Starting from April 2017, however, as a Debian extension this version of
383 .Nm mail
384 adds a few MIME headers to every outgoing mail in order to indicate
385 that the mail is sent as 8-bit plain text data that uses character
386 set encoding detected from the current
387 .Xr locale 7
388 settings.
389 The
390 .Fl a
391 command-line option can be used to override those headers, for example:
392 .Dl $ mail -a 'Content-Type: text/plain; charset="ISO-8859-1"'
393 sets header indicating legacy character encoding.
394 .Pp
395 .Sh SUMMARY
396 (Adapted from the
397 .Dq Mail Reference Manual . )
398 .Pp
399 Each command is typed on a line by itself, and may take arguments
400 following the command word.
401 The command need not be typed in its
402 entirety \(em the first command which matches the typed prefix is used.
403 For commands which take message lists as arguments, if no message
404 list is given, then the next message forward which satisfies the
405 command's requirements is used.
406 If there are no messages forward of
407 the current message, the search proceeds backwards, and if there are no
408 good messages at all,
409 .Nm mail
410 types
411 .Dq \&No applicable messages
412 and
413 aborts the command.
414 .Bl -tag -width delete
415 .It Ic -
416 Print out the preceding message.
417 If given a numeric
418 argument
419 .Ar n ,
420 goes to the
421 .Ar n Ns th
422 previous message and prints it.
423 .It Ic \&=
424 Prints the currently selected message number.
425 .It Ic \&?
426 Prints a brief summary of commands.
427 .It Ic \&!
428 Executes the shell
429 (see
430 .Xr sh 1
431 and
432 .Xr csh 1 )
433 command which follows.
434 .It Ic alias
435 .Pq Ic a
436 With no arguments, prints out all currently defined aliases.
437 With one
438 argument, prints out that alias.
439 With more than one argument, creates
440 a new alias or changes an old one.
441 .It Ic alternates
442 .Pq Ic alt
443 The
444 .Ic alternates
445 command is useful if you have accounts on several machines.
446 It can be used to inform
447 .Nm mail
448 that the listed addresses are really you.
449 When you
450 .Ic reply
451 to messages,
452 .Nm mail
453 will not send a copy of the message to any of the addresses
454 listed on the
455 .Ic alternates
456 list.
457 If the
458 .Ic alternates
459 command is given with no argument, the current set of alternate
460 names is displayed.
461 .It Ic chdir
462 .Pf ( Ic cd
463 or
464 .Ic ch )
465 Changes the user's working directory to that specified, if given.
466 If
467 no directory is given, then changes to the user's login directory.
468 .It Ic copy
469 .Pq Ic c
470 The
471 .Ic copy
472 command does the same thing that
473 .Ic save
474 does, except that it does not mark the messages it
475 is used on for deletion when you quit.
476 .It Ic delete
477 .Pq Ic d
478 Takes a list of messages as argument and marks them all as deleted.
479 Deleted messages will not be saved in
480 .Ar mbox ,
481 nor will they be available for most other commands.
482 .It Ic dp
483 (also
484 .Ic dt )
485 Deletes the current message and prints the next message.
486 If there is no next message,
487 .Nm mail
488 says
489 .Dq Li "\&No more messages."
490 .It Ic edit
491 .Pq Ic e
492 Takes a list of messages and points the text editor at each one in
493 turn.
494 On return from the editor, the message is read back in.
495 .It Ic exit
496 .Pf ( Ic ex
497 or
498 .Ic x )
499 Effects an immediate return to the shell without
500 modifying the user's system mailbox,
501 .Ar mbox
502 file, or edit file in
503 .Fl f .
504 .It Ic file
505 .Pq Ic fi
506 The same as
507 .Ic folder .
508 .It Ic folder
509 .Pq Ic fo
510 The
511 .Ic folder
512 command switches to a new mail file or folder.
513 With no
514 arguments, it tells you which file you are currently reading.
515 If you give it an argument, it will write out changes (such
516 as deletions) you have made in the current file and read in
517 the new file.
518 Some special conventions are recognized for
519 the name.
520 # means the previous file, % means your system
521 mailbox, %user means user's system mailbox, & means
522 your
523 .Ar mbox
524 file, and
525 +folder means a file in your folder
526 directory.
527 .It Ic folders
528 List the names of the folders in your folder directory.
529 .It Ic from
530 .Pq Ic f
531 Takes a list of messages and prints their message headers.
532 .It Ic headers
533 .Pq Ic h
534 Lists the current windowful of headers.
535 To view the next or previous group of headers, see the
536 .Ic z
537 command.
538 .It Ic help
539 A synonym for
540 .Ic \&? .
541 .It Ic hold
542 .Pf ( Ic ho ,
543 also
544 .Ic preserve )
545 Takes a message list and marks each
546 message therein to be saved in the
547 user's system mailbox instead of in
548 .Ar mbox .
549 Does not override the
550 .Ic delete
551 command.
552 .It Ic ignore
553 Add the list of header fields named to the
554 .Ar ignored list .
555 Header fields in the ignore list are not printed
556 on your terminal when you print a message.
557 This
558 command is very handy for suppression of certain machine-generated
559 header fields.
560 The
561 .Ic Type
562 and
563 .Ic Print
564 commands can be used to print a message in its entirety, including
565 ignored fields.
566 If
567 .Ic ignore
568 is executed with no arguments, it lists the current set of
569 ignored fields.
570 .It Ic inc
571 Incorporate any new messages that have arrived while mail
572 is being read.
573 The new messages are added to the end of the message list,
574 and the current message is reset to be the first new mail message.
575 This does not renumber the existing message list, nor
576 does it cause any changes made so far to be saved.
577 .It Ic list
578 .Pq Ic l
579 List the valid
580 .Nm
581 commands.
582 .It Ic mail
583 .Pq Ic m
584 Takes as argument login names and distribution group names and sends
585 mail to those people.
586 .It Ic mbox
587 Indicate that a list of messages be sent to
588 .Ar mbox
589 in your home directory when you quit.
590 This is the default
591 action for messages if you do
592 .Em not
593 have the
594 .Ic hold
595 option set.
596 .It Ic more
597 .Pq Ic \&mo
598 Takes a message list and invokes the pager on that list.
599 .It Ic next
600 .Pq Ic n
601 (like
602 .Ic +
603 or CR)
604 Goes to the next message in sequence and types it.
605 With an argument list, types the next matching message.
606 .It Ic preserve
607 .Pq Ic pre
608 A synonym for
609 .Ic hold .
610 .It Ic Print
611 .Pq Ic P
612 Like
613 .Ic print
614 but also prints out ignored header fields.
615 See also
616 .Ic print ,
617 .Ic ignore ,
618 and
619 .Ic retain .
620 .It Ic print
621 .Pq Ic p
622 Takes a message list and types out each message on the user's terminal.
623 .It Ic quit
624 .Pq Ic q
625 Terminates the session, saving all undeleted, unsaved messages in the
626 .Ar mbox
627 file in the user's login directory, preserving all messages marked with
628 .Ic hold
629 or
630 .Ic preserve
631 or never referenced in the user's system mailbox,
632 and removing all other messages from the user's system mailbox.
633 If new mail has arrived during the session, the message
634 .Dq Li "You have new mail"
635 is given.
636 If given while editing a
637 mailbox file with the
638 .Fl f
639 flag, then the edit file is rewritten.
640 A return to the shell is
641 effected, unless the rewrite of edit file fails, in which case the user
642 can escape with the
643 .Ic exit
644 command.
645 .It Ic Reply
646 .Pq Ic R
647 Reply to originator.
648 Does not reply to other
649 recipients of the original message.
650 .It Ic reply
651 .Pq Ic r
652 Takes a message list and sends mail to the sender and all
653 recipients of the specified message.
654 The default message must not be deleted.
655 .It Ic respond
656 A synonym for
657 .Ic reply .
658 .It Ic retain
659 Add the list of header fields named to the
660 .Ar retained list .
661 Only the header fields in the retain list
662 are shown on your terminal when you print a message.
663 All other header fields are suppressed.
664 The
665 .Ic Type
666 and
667 .Ic Print
668 commands can be used to print a message in its entirety.
669 If
670 .Ic retain
671 is executed with no arguments, it lists the current set of
672 retained fields.
673 .It Ic save
674 .Pq Ic s
675 Takes a message list and a filename and appends each message in
676 turn to the end of the file.
677 The filename in quotes, followed by the line
678 count and character count is echoed on the user's terminal.
679 .It Ic saveignore
680 .Ic saveignore
681 is to
682 .Ic save
683 what
684 .Ic ignore
685 is to
686 .Ic print
687 and
688 .Ic type .
689 Header fields thus marked are filtered out when
690 saving a message by
691 .Ic save
692 or when automatically saving to
693 .Ar mbox .
694 .It Ic saveretain
695 .Ic saveretain
696 is to
697 .Ic save
698 what
699 .Ic retain
700 is to
701 .Ic print
702 and
703 .Ic type .
704 Header fields thus marked are the only ones saved
705 with a message when saving by
706 .Ic save
707 or when automatically saving to
708 .Ar mbox .
709 .Ic saveretain
710 overrides
711 .Ic saveignore .
712 .It Ic set
713 .Pq Ic se
714 With no arguments, prints all variable values.
715 Otherwise, sets
716 option.
717 Arguments are of the form
718 .Ar option=value
719 (no space before or after =) or
720 .Ar option .
721 Quotation marks may be placed around any part of the assignment statement to
722 quote blanks or tabs, i.e.,
723 .Ic set indentprefix="->" .
724 .It Ic shell
725 .Pq Ic sh
726 Invokes an interactive version of the shell.
727 .It Ic size
728 Takes a message list and prints out the size in characters of each
729 message.
730 .It Ic source
731 The
732 .Ic source
733 command reads
734 commands from a file.
735 .It Ic top
736 Takes a message list and prints the top few lines of each.
737 The number of
738 lines printed is controlled by the variable
739 .Ic toplines
740 and defaults to five.
741 .It Ic Type
742 .Pq Ic T
743 Identical to the
744 .Ic Print
745 command.
746 .It Ic type
747 .Pq Ic t
748 A synonym for
749 .Ic print .
750 .It Ic unalias
751 Takes a list of names defined by
752 .Ic alias
753 commands and discards the remembered groups of users.
754 The group names
755 no longer have any significance.
756 .It Ic undelete
757 .Pq Ic u
758 Takes a message list and marks each message as not being deleted.
759 .It Ic unread
760 .Pq Ic U
761 Takes a message list and marks each message as not having been read.
762 .It Ic unset
763 Takes a list of option names and discards their remembered values;
764 the inverse of
765 .Ic set .
766 .It Ic visual
767 .Pq Ic v
768 Takes a message list and invokes the display editor on each message.
769 .It Ic write
770 .Pq Ic w
771 Similar to
772 .Ic save ,
773 except that
774 .Ic only
775 the message body
776 (without the header)
777 is saved.
778 Extremely useful for such tasks as sending and receiving source
779 program text over the message system.
780 .It Ic xit
781 .Pq Ic x
782 A synonym for
783 .Ic exit .
784 .It Ic z
785 .Nm mail
786 presents message headers in windowfuls as described under the
787 .Ic headers
788 command.
789 You can move
790 .Nm mail Ns 's
791 attention forward to the next window with the
792 .Ic z
793 command.
794 Also, you can move to the previous window by using
795 .Ic z- .
796 .El
797 .Ss Tilde/escapes
798 Here is a summary of the tilde escapes,
799 which are used when composing messages to perform
800 special functions.
801 Tilde escapes are only recognized at the beginning
802 of lines.
803 The name
804 .Dq tilde escape
805 is somewhat of a misnomer since the actual escape character can be set
806 by the option
807 .Ic escape .
808 .Pp
809 .Bl -tag -width Ds -compact
810 .It Ic ~b Ns Ar name ...
811 Add the given names to the list of carbon copy recipients but do not make
812 the names visible in the Cc: line ("blind" carbon copy).
813 .Pp
814 .It Ic ~c Ns Ar name ...
815 Add the given names to the list of carbon copy recipients.
816 .Pp
817 .It Ic ~d
818 Read the file
819 .Pa dead.letter
820 from your home directory into the message.
821 .Pp
822 .It Ic ~e
823 Invoke the text editor on the message collected so far.
824 After the
825 editing session is finished, you may continue appending text to the
826 message.
827 .Pp
828 .It Ic ~F Ns Ar messages
829 Identical to
830 .Ic ~f ,
831 except all message headers are included.
832 .Pp
833 .It Ic ~f Ns Ar messages
834 Read the named messages into the message being sent.
835 If no messages are specified, read in the current message.
836 Message headers currently being ignored (by the
837 .Ic ignore
838 or
839 .Ic retain
840 command) are not included.
841 .Pp
842 .It Ic ~h
843 Edit the message header fields by typing each one in turn and allowing
844 the user to append text to the end or modify the field by using the
845 current terminal erase and kill characters.
846 .Pp
847 .It Ic ~M Ns Ar messages
848 Identical to
849 .Ic ~m ,
850 except all message headers are included.
851 .Pp
852 .It Ic ~m Ns Ar messages
853 Read the named messages into the message being sent, indented by a
854 tab or by the value of
855 .Va indentprefix .
856 If no messages are specified,
857 read the current message.
858 Message headers currently being ignored (by the
859 .Ic ignore
860 or
861 .Ic retain
862 command) are not included.
863 .Pp
864 .It Ic ~p
865 Print out the message collected so far, prefaced by the message header
866 fields.
867 .Pp
868 .It Ic ~q
869 Abort the message being sent, copying the message to
870 .Pa dead.letter
871 in your home directory if
872 .Ic save
873 is set.
874 .It Ic ~R Ns Ar string
875 Use
876 .Ar string
877 as the Reply-To field.
878 .Pp
879 .It Ic ~r Ns Ar filename
880 .It Ic ~< Ns Ar filename
881 Read the named file into the message.
882 .Pp
883 .It Ic ~s Ns Ar string
884 Cause the named string to become the current subject field.
885 .Pp
886 .It Ic ~t Ns Ar name ...
887 Add the given names to the direct recipient list.
888 .Pp
889 .It Ic ~v
890 Invoke an alternate editor (defined by the
891 .Ev VISUAL
892 option) on the
893 message collected so far.
894 Usually, the alternate editor will be a
895 screen editor.
896 After you quit the editor, you may resume appending
897 text to the end of your message.
898 .Pp
899 .It Ic ~w Ns Ar filename
900 Write the message onto the named file.
901 .Pp
902 .It Ic ~x
903 Abort the message being sent.
904 No message is copied to
905 .Pa ~/dead.letter ,
906 even if
907 .Ic save
908 is set.
909 .Pp
910 .It Ic ~?
911 Prints a brief summary of tilde escapes.
912 .Pp
913 .It Ic ~! Ns Ar command
914 Execute the indicated shell command, then return to the message.
915 .Pp
916 .It Ic ~| Ns Ar command
917 Pipe the message through the command as a filter.
918 If the command gives
919 no output or terminates abnormally, retain the original text of the
920 message.
921 The command
922 .Xr fmt 1
923 is often used as
924 .Ic command
925 to rejustify the message.
926 .Pp
927 .It Ic ~: Ns Ar mail-command
928 .It Ic ~_ Ns Ar mail-command
929 Execute the given mail command.
930 Not all commands, however, are allowed.
931 .Pp
932 .It Ic ~~ Ns Ar string
933 Insert the string of text in the message prefaced by a single ~.
934 If
935 you have changed the escape character, then you should double
936 that character in order to send it.
937 .Pp
938 .It Ic ~.
939 Simulate end of file on input.
940 .El
941 .Ss Mail options
942 A number of options can be set in the
943 .Pa .mailrc
944 file to alter the behavior of
945 .Nm ,
946 controlled via the
947 .Ic set
948 and
949 .Ic unset
950 commands.
951 Options may be either binary, in which case it is only
952 significant to see whether they are set or not; or string, in which
953 case the actual value is of interest.
954 The binary options include the following:
955 .Bl -tag -width append
956 .It Ar append
957 Causes messages saved in
958 .Ar mbox
959 to be appended to the end rather than prepended.
960 This should always be set (perhaps in
961 .Pa /etc/mail.rc ) .
962 .It Ar ask , asksub
963 Causes
964 .Nm mail
965 to prompt you for the subject of each message you send.
966 If
967 you respond with simply a newline, no subject field will be sent.
968 .It Ar askbcc
969 Causes you to be prompted for additional blind carbon copy recipients at the
970 end of each message.
971 Responding with a newline indicates your
972 satisfaction with the current list.
973 .It Ar askcc
974 Causes you to be prompted for additional carbon copy recipients at the
975 end of each message.
976 Responding with a newline indicates your
977 satisfaction with the current list.
978 .It Ar autoinc
979 Causes new mail to be automatically incorporated when it arrives.
980 Setting this is similar to issuing the
981 .Ic inc
982 command at each prompt, except that the current message is not
983 reset when new mail arrives.
984 .It Ar autoprint
985 Causes the
986 .Ic delete
987 command to behave like
988 .Ic dp ;
989 thus, after deleting a message, the next one will be typed
990 automatically.
991 .It Ar debug
992 Setting the binary option
993 .Ar debug
994 is the same as specifying
995 .Fl d
996 on the command line and causes
997 .Nm mail
998 to output all sorts of information useful for debugging
999 .Nm mail .
1000 .It Ar dot
1001 The binary option
1002 .Ar dot
1003 causes
1004 .Nm mail
1005 to interpret a period alone on a line as the terminator
1006 of a message you are sending.
1007 .It Ar expandaddr
1008 Causes
1009 .Nm mail
1010 to expand message recipient addresses, as explained in the section
1011 .Sx Recipient address specifications .
1012 .It Ar from
1013 Causes
1014 .Nm mail
1015 to use the specified sender address in the
1016 .Dq From:
1017 field of the message header.
1018 A stripped down version of the address is also used in the message envelope.
1019 If unset, the message will not include an explicit sender address and
1020 a default value will be added by the MTA, typically
1021 .Dq user@host .
1022 This value can be overridden by specifying the
1023 .Fl r
1024 flag on the command line.
1025 .It Ar hold
1026 This option is used to hold messages in the system mailbox
1027 by default.
1028 .It Ar ignore
1029 Causes interrupt signals from your terminal to be ignored and echoed as
1030 @'s.
1031 .It Ar ignoreeof
1032 An option related to
1033 .Ar dot
1034 is
1035 .Ar ignoreeof
1036 which makes
1037 .Nm mail
1038 refuse to accept a control-D as the end of a message.
1039 .Ar ignoreeof
1040 also applies to
1041 .Nm mail
1042 command mode.
1043 .It Ar keep
1044 Setting this option causes
1045 .Nm
1046 to truncate your system mailbox instead of deleting it
1047 when it's empty.
1048 .It Ar keepsave
1049 Messages saved with the
1050 .Ic save
1051 command are not normally saved in
1052 .Ar mbox
1053 at quit time.
1054 Use this option to retain those messages.
1055 .It Ar metoo
1056 Usually, when a group is expanded that contains the sender, the sender
1057 is removed from the expansion.
1058 Setting this option causes the sender
1059 to be included in the group.
1060 .It Ar noheader
1061 Setting the option
1062 .Ar noheader
1063 is the same as giving the
1064 .Fl N
1065 flag on the command line.
1066 .It Ar nosave
1067 Normally, when you abort a message with two interrupt characters
1068 (usually control-C),
1069 .Nm mail
1070 copies the partial letter to the file
1071 .Pa dead.letter
1072 in your home directory.
1073 Setting the binary option
1074 .Ar nosave
1075 prevents this.
1076 .It Ar quiet
1077 Suppresses the printing of the version when first invoked.
1078 .It Ar Replyall
1079 Reverses the sense of
1080 .Ic reply
1081 and
1082 .Ic Reply
1083 commands.
1084 .It Ar searchheaders
1085 If this option is set, then a message-list specifier in the form
1086 .Dq /x:y
1087 will expand to all messages containing the substring
1088 .Sq y
1089 in the header
1090 field
1091 .Sq x .
1092 The string search is case insensitive.
1093 If
1094 .Sq x
1095 is omitted, it will default to the
1096 .Dq Subject
1097 header field.
1098 The form
1099 .Dq /to:y
1100 is a special case, and will expand
1101 to all messages containing the substring
1102 .Sq y
1103 in the
1104 .Dq To ,
1105 .Dq Cc
1106 or
1107 .Dq Bcc
1108 header fields.
1109 The check for
1110 .Dq to
1111 is case sensitive, so that
1112 .Dq /To:y
1113 can be used to limit the search for
1114 .Sq y
1115 to just the
1116 .Dq To:
1117 field.
1118 .It Ar skipempty
1119 Don't send messages with an empty body.
1120 .It Ar verbose
1121 Setting the option
1122 .Ar verbose
1123 is the same as using the
1124 .Fl v
1125 flag on the command line.
1126 When
1127 .Nm
1128 runs in verbose mode,
1129 the actual delivery of messages is displayed on the user's
1130 terminal.
1131 .El
1132 .Ss Option string values
1133 .Bl -tag -width Va
1134 .It Ev EDITOR
1135 Pathname of the text editor to use in the
1136 .Ic edit
1137 command and
1138 .Ic ~e
1139 escape.
1140 If not defined,
1141 .Pa /usr/bin/ex
1142 is used.
1143 .It Ev LISTER
1144 Pathname of the directory lister to use in the
1145 .Ic folders
1146 command.
1147 Default is
1148 .Pa /bin/ls .
1149 .It Ev MBOX
1150 The name of the
1151 .Ar mbox
1152 file.
1153 It can be the name of a folder.
1154 The default is
1155 .Dq Li mbox
1156 in the user's home directory.
1157 .It Ev PAGER
1158 Pathname of the program to use in the
1159 .Ic more
1160 command or when the
1161 .Ar crt
1162 variable is set.
1163 The default paginator
1164 .Xr more 1
1165 is used if this option is not defined.
1166 .It Ev REPLYTO
1167 If set, will be used to initialize the Reply-To field for outgoing
1168 messages.
1169 .It Ev SHELL
1170 Pathname of the shell to use in the
1171 .Ic !\&
1172 command and the
1173 .Ic ~!\&
1174 escape.
1175 A default shell is used if this option is
1176 not defined.
1177 .It Ev VISUAL
1178 Pathname of the text editor to use in the
1179 .Ic visual
1180 command and
1181 .Ic ~v
1182 escape.
1183 If not defined,
1184 .Pa /usr/bin/vi
1185 is used.
1186 .It Ar crt
1187 The valued option
1188 .Ar crt
1189 is used as a threshold to determine how long a message must
1190 be before
1191 .Ev PAGER
1192 is used to read it.
1193 If
1194 .Ar crt
1195 is set without a value,
1196 then the height of the terminal screen stored in the system
1197 is used to compute the threshold (see
1198 .Xr stty 1 ) .
1199 .It Ar escape
1200 If defined, the first character of this option gives the character to
1201 use in the place of ~ to denote escapes.
1202 .It Ar folder
1203 The name of the directory to use for storing folders of
1204 messages.
1205 If this name begins with a
1206 .Ql / ,
1207 .Nm mail
1208 considers it to be an absolute pathname; otherwise, the
1209 folder directory is found relative to your home directory.
1210 .It Ar indentprefix
1211 String used by the
1212 .Ic ~m
1213 tilde escape for indenting messages, in place of the normal tab character
1214 .Pq Sq ^I .
1215 Be sure to quote the value if it contains
1216 spaces or tabs.
1217 .It Ar record
1218 If defined, gives the pathname of the file used to record all outgoing
1219 mail.
1220 If not defined, then outgoing mail is not so saved.
1221 .It Ar screen
1222 Size of window of message headers for
1223 .Ic z .
1224 .It Ar sendmail
1225 Pathname to an alternative mail delivery system.
1226 .It Ar toplines
1227 If defined, gives the number of lines of a message to be printed out
1228 with the
1229 .Ic top
1230 command; normally, the first five lines are printed.
1231 .El
1232 .Sh ENVIRONMENT
1233 .Nm mail
1234 utilizes the
1235 .Ev HOME ,
1236 .Ev LOGNAME ,
1237 .Ev USER ,
1238 .Ev SHELL ,
1239 .Ev DEAD ,
1240 .Ev PAGER ,
1241 .Ev LISTER ,
1242 .Ev EDITOR ,
1243 .Ev VISUAL ,
1244 .Ev REPLYTO ,
1245 .Ev MAIL ,
1246 .Ev MAILRC ,
1247 and
1248 .Ev MBOX
1249 environment variables.
1250 .Pp
1251 If the
1252 .Ev MAIL
1253 environment variable is set, its value is used as the path to the
1254 user's mail spool.
1255 .Sh FILES
1256 .Bl -tag -width /usr/share/bsd\-mailx/mail.*help -compact
1257 .It Pa /var/mail/*
1258 post office (unless overridden by the
1259 .Ev MAIL
1260 environment variable)
1261 .It Pa ~/mbox
1262 user's old mail
1263 .It Pa ~/.mailrc
1264 file giving initial mail commands; can be overridden by setting the
1265 .Ev MAILRC
1266 environment variable
1267 .It Pa /tmp/R*
1268 temporary files
1269 .It Pa /usr/share/bsd\-mailx/mail.*help
1270 help files
1271 .It Pa /etc/mail.rc
1272 system initialization file
1273 .El
1274 .Sh EXIT STATUS
1275 .Ex -std mail
1276 .Sh SEE ALSO
1277 .Xr fmt 1 ,
1278 .Xr newaliases 1 ,
1279 .Xr vacation 1 ,
1280 .Xr aliases 5 ,
1281 .Xr mail.local 8 ,
1282 .Xr newaliases 8 ,
1283 .Xr sendmail 8 ,
1284 .Xr smtpd 8
1285 .Rs
1286 .\" 4.4BSD USD:7
1287 .%A Kurt Shoens
1288 .%T Mail Reference Manual
1289 .%B 4.4BSD User's Supplementary Documents (USD)
1290 .Re
1291 .Sh STANDARDS
1292 The
1293 .Nm mailx
1294 utility is compliant with the
1295 .St -p1003.1-2008
1296 specification.
1297 .Pp
1298 The flags
1299 .Op Fl iNnu
1300 are marked by
1301 .St -p1003.1-2008
1302 as being optional.
1303 .Pp
1304 The flags
1305 .Op Fl eFH
1306 are marked by
1307 .St -p1003.1-2008
1308 as being optional,
1309 and are not supported by this implementation of
1310 .Nm mailx .
1311 .Pp
1312 The flags
1313 .Op Fl abcdEIrv
1314 are extensions to the specification.
1315 .Sh HISTORY
1316 A
1317 .Nm mail
1318 command appeared in
1319 .At v1 .
1320 This man page is derived from the
1321 .%T "Mail Reference Manual"
1322 originally written by Kurt Shoens.
1323 .Sh BUGS
1324 Usually,
1325 .Nm Mail
1326 and
1327 .Nm mailx
1328 are just links to
1329 .Nm mail ,
1330 which can be confusing.