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