xref: /netbsd-src/usr.bin/mail/mail.1 (revision 404fbe5fb94ca1e054339640cabb2801ce52dd30)
1.\"	$NetBSD: mail.1,v 1.54 2008/12/08 11:32:18 wiz 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 December 7, 2008
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
42.Op Fl EIinv
43.Op Fl a Ar file
44.Op Fl b Ar bcc-addr
45.Op Fl c Ar cc-addr
46.Op Fl s Ar subject
47.Ar to-addr ...
48.Op Ar sendmail-flags
49.Nm
50.Op Fl EIiNnv
51.Op Fl H Ns Op colon-modifier
52.Fl f
53.Op Ar name
54.Nm
55.Op Fl EIiNnv
56.Op Fl H Ns Op colon-modifier
57.Op Fl u Ar user
58.Sh DESCRIPTION
59.Nm
60is an intelligent mail processing system, which has
61a command syntax reminiscent of
62.Xr \&ed 1
63with lines replaced by messages.
64.Pp
65.Bl -tag -width flag
66.It Fl a
67Attach
68.Ar file
69to the message.
70.It Fl b
71Send blind carbon copies to
72.Ar list .
73List should be a comma-separated list of names.
74.It Fl c
75Send carbon copies to
76.Ar list
77of users.
78.It Fl E
79Don't send messages with an empty body.
80This is useful for piping errors from cron scripts.
81.It Fl f
82Read in the contents of your
83.Ar mbox
84(or the specified file)
85for processing; when you
86.Ic quit ,
87.Nm
88writes undeleted messages back to this file.
89.It Fl H
90Print the header summaries and exit.
91The optional colon-modifier string must begin with a
92.Ql \&:
93and be followed by one or more of the characters described in the
94.Sx Specifying messages
95section below.
96E.g.,
97.Do
98.Nm
99.Fl H Ns :n
100.Dc
101will display just new message headers.
102.It Fl I
103Forces mail to run in interactive mode even when
104input isn't a terminal.
105In particular, the
106.Ic \&~
107special
108character when sending mail is only active in interactive mode.
109.It Fl i
110Ignore tty interrupt signals.
111This is particularly useful when using
112.Nm
113on noisy phone lines.
114.It Fl N
115Inhibits the initial display of message headers
116when reading mail or editing a mail folder.
117.It Fl n
118Inhibits reading
119.Pa /etc/mail.rc
120upon startup.
121.It Fl s
122Specify subject on command line
123(only the first argument after the
124.Fl s
125flag is used as a subject; be careful to quote subjects
126containing spaces.)
127.It Fl u
128Is equivalent to:
129.Pp
130.Dl mail -f /var/mail/user
131.It Fl v
132Verbose mode.
133The details of delivery are displayed on the user's terminal.
134.El
135.Ss Sending mail
136To send a message to one or more people,
137.Nm
138can be invoked with arguments which are the names of people to
139whom the mail will be sent.
140You are then expected to type in your message, followed by a
141.Ql control-D
142at the beginning of a line.
143.Pp
144Any flags following the list of recipients, will be passed, together
145with their arguments, directly to
146.Xr sendmail 1 .
147For example to change your
148.Dv From
149address to
150.Dv somebody@somewhere.net
151you can specify:
152.Pp
153.Dl mail recipient -f somebody@somewhere.net
154.Pp
155To prevent multiple copies of a message being sent to the same
156address, duplicate addresses (after alias expansion) are removed from
157the
158.Ar bcc-addr ,
159.Ar cc-addr ,
160and
161.Ar to-addr
162lists.
163In addition, addresses on the
164.Ar cc-addr
165and
166.Ar to-addr
167lists are removed if they occur on the
168.Ar bcc-addr
169list and addresses on the
170.Ar cc-addr
171list are removed if they occur on the
172.Ar to-addr
173list.
174If the
175.Ar to-addr
176list is empty after these deletions, most systems will insert the line
177.Dq To: undisclosed recipients:; .
178.Pp
179The section below
180.Sx Replying to or originating mail ,
181describes some features of
182.Nm
183available to help you compose your letter.
184.Ss Reading mail
185In normal usage
186.Nm
187is given no arguments and checks your mail out of the post office,
188then prints out a one line header of each message found.
189The current message is initially the first message (numbered 1)
190and can be printed using the
191.Ic print
192command (which can be abbreviated
193.Ic p ) .
194You can move among the messages much as you move between lines in
195.Xr \&ed 1 ,
196with the commands
197.Ic \&+
198and
199.Ic \&\-
200moving backwards and forwards, and simple numbers.
201.Ss Disposing of mail
202After examining a message you can
203.Ic delete
204.Pq Ic d
205the message or
206.Ic reply
207.Pq Ic r
208to it.
209Deletion causes the
210.Nm
211program to forget about the message.
212This is not irreversible; the message can be
213.Ic undeleted
214.Pq Ic u
215by giving its number, or the
216.Nm
217session can be aborted by giving the
218.Ic exit
219.Pq Ic x
220command.
221Deleted messages will, however, usually disappear never to be seen again.
222.Ss Specifying messages
223Many commands (e.g.,
224.Ic delete ,
225.Ic from ,
226and
227.Ic print )
228accept a list of messages as an argument.
229Messages may be specified by their message number, by a range of
230messages, or by a pattern string matching certain fields in the header
231as described below.
232These message
233.Dq specs
234may be combined by the usual binary boolean operations
235.Ql \*[Am] ,
236.Ql \&| ,
237and
238.Ql \&^ ,
239which denote, respectively, a logical
240.Dq and ,
241.Dq or ,
242and
243.Dq xor .
244Logical expressions may be grouped with parentheses
245.Ql \&(
246and
247.Ql \&)
248and
249negated with
250.Ql \&! .
251If the binary operator is missing between two message specs, it is
252assumed to be a
253.Ql \&| .
254This is for simplicity, backwards compatibility, and also to to
255facilitate using the
256.Ql \&|
257symbol to denote a pipe.
258(See
259.Ar enable-pipes . )
260.Pp
261Besides the obvious (base10) message numbers, the characters
262.Ql \&^ ,
263.Ql \&- ,
264.Ql \&. ,
265.Ql \&+ ,
266and
267.Ql \&$
268denote, respectively, the first message, the message before the
269.Dq dot
270.Pq the current message ,
271the
272.Dq dot
273message, the message following the
274.Dq dot ,
275and the last message.
276.Pp
277A
278.Dq message range
279consists of two message numbers separated by a
280.Ql \&- .
281A
282.Ql \&*
283denotes all messages and is equivalent to
284.Ql ^-$ .
285.Pp
286A pattern is a string (not beginning with any of the above special
287characters).
288If it does not begin with a
289.Ql \&/ ,
290it is compared with the senders address.
291If it begins with a
292.Ql \&/ ,
293and
294.Ar searchheaders
295is not defined, the remainder of the string is compared with the
296subject field.
297(See
298.Ar searchheaders
299for searching other header fields or the message body.)
300If
301.Ar regex-search
302is not defined, then the comparison is a simple case insensitive
303substring match.
304(See
305.Ar regex-search
306for regular expression matches.)
307.Pp
308A list of messages may be restricted by a
309.Dq colon-modifier
310string, i.e., a
311.Ql \&:
312followed by one or more of the characters:
313.Bd -literal -offset indent
314d	deleted
315e	edited
316m	mboxed
317n	new
318o	old
319p	preserved
320r	read
321s	saved
322t	tagged
323u	unread and not new
324!	invert the meaning of the colon-modifiers
325.Ed
326.Pp
327If there are no address specifications other than colon-modifiers,
328the colon-modifiers apply to all messages.
329Thus
330.Dq Li from netbsd :n
331would display the headers of all new messages with
332.Ql netbsd
333in the sender's address, while
334.Dq Li from :!r
335and
336.Dq Li from :nu
337would both display all new and unread messages.
338Multiple colon-modifiers may be specified and a single
339.Ql \&:
340with no letters following indicates the colon-modifier from the
341preceding command.
342.Pp
343For example:
344.Bd -literal -offset indent
345from 1 12 3-5
346.Ed
347.Pp
348would display the headers from messages 1, 3, 4, 5, and 12.
349.Bd -literal -offset indent
350from anon \*[Am] ( /foo | /bar )
351.Ed
352.Pp
353would display all headers that had
354.Ql anon
355in the sender's address and either
356.Ql foo
357or
358.Ql bar
359in the subject line.
360.Pp
361Generally, commands cannot select messages that are not displayed,
362such as deleted or hidden messages, the exception being the
363.Ic undelete
364command.
365.Ss Replying to or originating mail
366You can use the
367.Ic reply
368command to set up a response to a message, sending it back to the
369person who it was from.
370Text you then type in, up to an end-of-file,
371defines the contents of the message.
372While you are composing a message,
373.Nm
374treats lines beginning with the character
375.Ic \&~
376specially.
377For instance, typing
378.Ic \&~m
379(alone on a line) will place a copy
380of the current message into the response right shifting it by a tab stop
381(see
382.Em indentprefix
383variable, below).
384Other escapes will set up subject fields, add and delete recipients
385to the message, and allow you to escape to an editor to revise the
386message or to a shell to run some commands.
387(These options are given in the summary below.)
388.Ss Ending a mail processing session
389You can end a
390.Nm
391session with the
392.Ic quit
393.Pq Ic q
394command.
395Messages which have been examined go to your
396.Ar mbox
397file unless they have been deleted in which case they are discarded.
398Unexamined messages go back to the post office.
399(See the
400.Fl f
401option above).
402.Ss Personal and system wide distribution lists
403It is also possible to create a personal distribution lists so that,
404for instance, you can send mail to
405.Dq Li cohorts
406and have it go
407to a group of people.
408Such lists can be defined by placing a line like
409.Pp
410.Dl alias cohorts bill ozalp jkf mark kridle@ucbcory
411.Pp
412in the file
413.Pa \&.mailrc
414in your home directory.
415The current list of such aliases can be displayed with the
416.Ic alias
417command in
418.Nm .
419System wide distribution lists can be created by editing
420.Pa /etc/mail/aliases ,
421see
422.Xr aliases 5
423and
424.Xr sendmail 1 ;
425these are kept in a different syntax.
426In mail you send, personal aliases will be expanded in mail sent
427to others so that they will be able to
428.Ic reply
429to the recipients.
430System wide
431.Ic aliases
432are not expanded when the mail is sent,
433but any reply returned to the machine will have the system wide
434alias expanded as all mail goes through
435.Xr sendmail 1 .
436.Ss Network mail (ARPA, UUCP, Berknet)
437See
438.Xr mailaddr 7
439for a description of network addresses.
440.Pp
441.Nm
442has a number of options which can be set in the
443.Pa .mailrc
444file to alter its behavior; thus
445.Dq Li set askcc
446enables the
447.Ar askcc
448feature.
449(These options are summarized below.)
450.Sh SUMMARY
451(Adapted from the
452.Dq Mail Reference Manual )
453.Pp
454Each command is typed on a line by itself, and may take arguments
455following the command word.
456The command need not be typed in its
457entirety \- the first command which matches the typed prefix is used.
458For commands which take message lists as arguments, if no message
459list is given, then the next message forward which satisfies the
460command's requirements is used.
461If there are no messages forward of the current message, the search
462proceeds backwards, and if there are no good messages at all,
463.Nm
464types
465.Dq Li \&No applicable messages
466and aborts the command.
467.Bl -tag -width delete
468.It Ic \&!
469Executes the shell
470(see
471.Xr sh 1
472and
473.Xr csh 1 )
474command which follows.
475.It Ic \&\-
476Print out the preceding message.
477If given a numeric
478argument
479.Ar n ,
480goes to the
481.Ar n Ap th
482previous message and prints it.
483.It Ic \&=
484With no argument, it displays the current message number.
485Otherwise, set the current message number to its first argument.
486.It Ic \&?
487Prints a brief summary of commands.
488.It Ic \&|
489Pipe the current message body through the shell
490(see
491.Xr sh 1
492and
493.Xr csh 1 )
494command which follows.
495.It Ic Detach
496Like
497.Ic detach
498but also saves MIME parts that don't have a filename associated with
499them.
500For the unnamed parts, a filename is suggested containing the message
501and part numbers, and the subtype.
502.It Ic More
503.Pq Ic M
504Like
505.Ic more
506but also prints out ignored header fields.
507.It Ic Page
508.Pq Ic \&Pa
509A synonym for
510.Ic More .
511.It Ic Print
512.Pq Ic P
513Like
514.Ic print
515but also prints out ignored header fields.
516See also
517.Ic print ,
518.Ic more ,
519.Ic page ,
520.Ic type ,
521.Ic view ,
522.Ic ignore ,
523and
524.Ic retain .
525.It Ic Reply
526.Pq Ic R
527Reply to originator.
528Does not reply to other recipients of the original message.
529(See
530.Ic reply . )
531.It Ic Save
532.Pq Ic S
533Same as
534.Ic save
535except that all header fields are saved ignoring the
536.Ic saveignore
537or
538.Ic saveretain
539lists.
540.It Ic Type
541.Pq Ic T
542Identical to the
543.Ic Print
544command.
545.It Ic View
546.Pq Ic V
547Like
548.Ic Print
549but has the opposite MIME decoding behavior.
550(See the
551.Ar mime-decode-message
552variable.)
553.It Ic alias
554.Pq Ic a
555With no arguments, prints out all currently-defined aliases.
556With one argument, prints out that alias.
557With more than one argument, creates
558a new alias or changes an old one.
559.It Ic alternates
560.Pq Ic alt
561The
562.Ic alternates
563command is useful if you have accounts on several machines.
564It can be used to inform
565.Nm
566that the listed addresses are really you.
567When you
568.Ic reply
569to messages,
570.Nm
571will not send a copy of the message to any of the addresses
572listed on the
573.Ic alternates
574list.
575If the
576.Ic alternates
577command is given with no argument, the current set of alternative
578names is displayed.
579.It Ic bounce
580Takes a list of messages and prompts for an address to bounce the
581messages to.
582If no message is specified, the current message is used.
583All the original header fields are preserved except for the
584.Ql Delivered-To ,
585.Ql X-Original-To
586and
587.Ql Status
588fields.
589The new
590.Ql To
591field contains the bounce address(es) plus any addresses in the old
592.Ql To
593field minus the user's local address and any on the alternates list.
594(See the
595.Ic alternates
596command.)
597.It Ic chdir
598.Pq Ic c
599Changes the user's working directory to that specified, if given.
600If no directory is given, then changes to the user's login directory.
601.It Ic copy
602.Pq Ic co
603The
604.Ic copy
605command does the same thing that
606.Ic save
607does, except that it does not mark the messages it
608is used on for deletion when you quit.
609.It Ic deldups
610Delete duplicate messages based on their
611.Ql Message-Id
612field, keeping the first one in the current sort order.
613This can be useful with replies to a mailing list that are also CCed
614to a subscriber.
615(The same thing can also be accomplished with the threading and
616tagging commands.)
617.It Ic delete
618.Pq Ic d
619Takes a list of messages as an argument and marks them all as deleted.
620Deleted messages will not be saved in
621.Ar mbox ,
622nor will they be available for most other commands.
623.It Ic detach
624Takes a message list followed by a target directory as arguments,
625decodes each MIME part in the message list, and saves it in the target
626directory.
627If the message list is empty, use the current message.
628If the directory is not specified, use the directory specified by
629.Ar mime-detach-dir
630variable and, if that is empty, default to the directory
631.Nm
632was started in.
633For each MIME part in the message list, the filename is displayed for
634confirmation or changes.
635If an empty name is entered, the part is skipped.
636If the filename already exists, the user will be prompted before
637overwriting it.
638(See the
639.Ar mime-detach-batch
640and
641.Ar mime-detach-overwrite
642variables to change this behavior.)
643Only MIME parts with an associated filename in the
644.Ql Content-Type
645or
646.Ql Content-Disposition
647fields are decoded.
648(See
649.Ic Detach
650to detach all parts.)
651The MIME extension hooks and character set conversion are ignored.
652.It Ic dp
653(also
654.Ic dt )
655Deletes the current message and prints the next message.
656If there is no next message,
657.Nm
658says
659.Dq Li "at EOF" .
660.It Ic down
661Go down one level in the thread.
662If given a message number, it descends the thread below that message,
663otherwise it descends from the current message (dot).
664.It Ic edit
665.Pq Ic e
666Takes a list of messages and points the text editor at each one in
667turn.
668On return from the editor, the message is read back in.
669.It Ic else
670Switch the command execution condition set by the previous
671.Ic if ,
672.Ic ifdef ,
673or
674.Ic ifndef
675command.
676.It Ic endif
677Terminate an
678.Ic if ,
679.Ic ifdef ,
680or
681.Ic ifndef
682command.
683.It Ic exit
684.Po Ic ex
685or
686.Ic x
687.Pc
688Effects an immediate return to the Shell without
689modifying the user's system mailbox, his
690.Ar mbox
691file, or his edit file in
692.Fl f .
693.It Ic expose
694Expose the thread structure so all messages appear in header listings.
695(See
696.Ar hide
697for the inverse.)
698The default header prompt will indent each header line one space for
699each level in the threading.
700The
701.Dq Li "%?* ?"
702format string does this.
703.It Ic file
704.Pq Ic fi
705The same as
706.Ic folder .
707.It Ic flatten
708For each message number in the argument list, or the current thread if
709no message list is given, promote all exposed children to the same
710thread level.
711.It Ic folders
712List the names of the folders in your folder directory.
713.It Ic folder
714.Pq Ic fo
715The
716.Ic folder
717command switches to a new mail file or folder.
718With no arguments, it tells you which file you are currently reading.
719If you give it an argument, it will write out changes (such
720as deletions) you have made in the current file and read in
721the new file.
722Some special conventions are recognized for the name.
723.Ql #
724means the previous file,
725.Ql %
726means your system mailbox,
727.Ql %user
728means user's system mailbox,
729.Ql \*[Am]
730means your
731.Ar mbox
732file, and
733.Ql +file
734means a file in your folder directory.
735.It Ic forward
736Takes a list of messages and prompts for an address (or addresses) to
737forward each message to.
738If no message list is specified, the current message is used.
739The mail editor is run for each message allowing the user to enter a
740message that will precede the forward message.
741The message is sent as a multipart/mixed MIME encoded message.
742All header fields except the
743.Ql Status
744field are included.
745.It Ic from
746.Pq Ic f
747Takes a list of messages and prints their message headers.
748.It Ic headers
749.Pq Ic h
750Lists the current range of headers, which is an 18\-message group.
751If a
752.Ql \&+
753argument is given, then the next 18\-message group is printed, and
754if a
755.Ql \&\-
756argument is given, the previous 18\-message group is printed.
757.It Ic help
758A synonym for
759.Ic \&?
760.It Ic hide
761Collapse the threads so that only the head of each thread is shown,
762hiding the subthreads.
763(See
764.Ar expose
765for the inverse.)
766.It Ic hidetags
767Restrict the display to untagged messages.
768In threaded mode, subthreads that connect directly to an untagged
769message are also displayed, including tagged messages in the
770connecting chain.
771.It Ic hidethreads
772The same as
773.Ar hide .
774.It Ic hold
775.Po Ic ho ,
776also
777.Ic preserve
778.Pc
779Takes a message list and marks each message therein to be saved in
780the user's system mailbox instead of in
781.Ar mbox .
782Does not override the
783.Ic delete
784command.
785.It Ic if
786Execute commands that follow depending on the operating mode.
787The current supported modes are
788.Ql receiving ,
789.Ql sending ,
790and
791.Ql headersonly .
792For example, one use might be something like:
793.Bd -literal -offset 0
794if headersonly
795  set header-format="%P%Q%3i %-21.20f %m/%d %R %3K \\"%q\\""
796else
797  set header-format="%P%Q%?\*[Am] ?%3i %-21.20f %a %b %e %R %3K/%-5O \\"%q\\""
798endif
799.Ed
800.It Ic ifdef
801Execute commands that follow if the specified variable is defined.
802Note: This includes environment variables.
803.It Ic ifndef
804Execute commands that follow if the specified variable is not
805defined.
806.It Ic ignore
807Add the list of header fields named to the
808.Ar ignored list .
809Header fields in the ignore list are not printed
810on your terminal when you print a message.
811This command is very handy for suppression of certain machine-generated
812header fields.
813The
814.Ic Type
815and
816.Ic Print
817commands can be used to print a message in its entirety, including
818ignored fields.
819If
820.Ic ignore
821is executed with no arguments, it lists the current set of
822ignored fields.
823.It Ic inc
824Incorporate any new messages that have arrived while mail
825is being read.
826The new messages are added to the end of the message list,
827and the current message is reset to be the first new mail message.
828This does not renumber the existing message list, nor does
829it cause any changes made so far to be saved.
830.It Ic invtags
831Invert the tags on a list of messages or the current message if none
832are given.
833Note: this will not affect any currently deleted messages.
834.It Ic mail
835.Pq Ic m
836Takes as argument login names and distribution group names and sends
837mail to those people.
838.It Ic mbox
839Indicate that a list of messages be sent to
840.Ic mbox
841in your home directory when you quit.
842This is the default action for messages if you do
843.Em not
844have the
845.Ic hold
846option set.
847.It Ic mkread
848.Pq Ic mk
849Takes a message list and marks each message as
850having been read.
851.It Ic more
852.Pq Ic \&mo
853Takes a message list and invokes the pager on that list.
854.It Ic next
855.Pf ( Ic n ,
856like
857.Ic \&+
858or
859.Tn CR )
860Goes to the next message in sequence and types it.
861With an argument list, types the next matching message.
862.It Ic page
863.Pq Ic pa
864A synonym for
865.Ic more .
866.It Ic preserve
867.Pq Ic pre
868A synonym for
869.Ic hold .
870.It Ic print
871.Pq Ic p
872Takes a message list and types out each message on the user's terminal.
873.It Ic quit
874.Pq Ic q
875Terminates the session, saving all undeleted, unsaved messages in
876the user's
877.Ar mbox
878file in his login directory, preserving all messages marked with
879.Ic hold
880or
881.Ic preserve
882or never referenced in his system mailbox, and removing all other
883messages from his system mailbox.
884If new mail has arrived during the session, the message
885.Dq Li "You have new mail"
886is given.
887If given while editing a mailbox file with the
888.Fl f
889flag, then the edit file is rewritten.
890A return to the Shell is effected, unless the rewrite of edit file
891fails, in which case the user can escape with the
892.Ic exit
893command.
894.It Ic reply
895.Pq Ic r
896Takes a message list and sends mail to the sender and all
897recipients of the specified message.
898The default message must not be deleted.
899(See the
900.Ic Reply
901command and the
902.Ar Replyall
903variable.)
904.It Ic respond
905A synonym for
906.Ic reply .
907.It Ic retain
908Add the list of header fields named to the
909.Ar retained list .
910Only the header fields in the retained list
911are shown on your terminal when you print a message.
912All other header fields are suppressed.
913The
914.Ic Type
915and
916.Ic Print
917commands can be used to print a message in its entirety.
918If
919.Ic retain
920is executed with no arguments, it lists the current set of
921retained fields.
922.Ic Retain
923overrides
924.Ic save .
925.It Ic reverse
926Reverse the order of the messages in at the current thread level.
927This is completely equivalent to
928.Dq Li sort \&! .
929.It Ic save
930.Pq Ic s
931Takes a message list and a filename and appends each message in
932turn to the end of the file.
933The filename in quotes, followed by the line
934count and character count is echoed on the user's terminal.
935.It Ic set
936.Pq Ic se
937With no arguments, prints all variable values.
938Otherwise, sets option.
939Arguments are of the form
940.Ar option=value
941(no space before or after =) or
942.Ar option .
943Quotation marks may be placed around any part of the assignment
944statement to quote blanks or tabs, i.e.
945.Dq Li "set indentprefix=\*q-\*[Gt]\*q"
946Inside single quotes everything is parsed literally, including
947.Sq \e
948escaped characters.
949Inside double quotes
950.Sq \e
951character escapes are interpreted.
952This is an extension as POSIX specifies that
953.Sq \e
954should be left uninterpreted for both single and double quoted strings.
955.It Ic saveignore
956.Ic Saveignore
957is to
958.Ic save
959what
960.Ic ignore
961is to
962.Ic print
963and
964.Ic type .
965Header fields thus marked are filtered out when
966saving a message by
967.Ic save
968or when automatically saving to
969.Ar mbox .
970.\" .pl +1
971.It Ic saveretain
972.Ic Saveretain
973is to
974.Ic save
975what
976.Ic retain
977is to
978.Ic print
979and
980.Ic type .
981Header fields thus marked are the only ones saved
982with a message when saving by
983.Ic save
984or when automatically saving to
985.Ar mbox .
986.Ic Saveretain
987overrides
988.Ic saveignore .
989.It Ic shell
990.Pq Ic sh
991Invokes an interactive version of the shell.
992.It Ic show
993.Pq Ic sho
994Takes a list of variables and prints out their values in the form
995.Ar option=value .
996If the list is empty, all variable values are shown.
997.It Ic showtags
998Display all current messages, tagged or not, unless they are in a
999hidden thread.
1000.It Ic showthreads
1001The same as
1002.Ar expose .
1003.It Ic size
1004Takes a message list and prints out the size in characters of each
1005message.
1006.It Ic smopts
1007Takes an
1008.Dq address-spec
1009followed by the sendmail flags that should be used when sending mail
1010to an address that matches that
1011.Dq address-spec .
1012If no sendmail flags are specified, then list the sendmail flags in
1013effect for the
1014.Dq address-spec .
1015If the
1016.Dq address-spec
1017is also omitted, then list all
1018.Ic smopts
1019settings.
1020The
1021.Dq address-spec
1022may be an alias, address, domain (beginning with a
1023.Ql \&@ ) ,
1024or subdomain
1025(beginning with a
1026.Ql \&. ) .
1027If mail is sent to multiple users, the sendmail flags are
1028used only if the flags are the same for each recipients.
1029If
1030.Ar smopts-verify
1031is set, then you will be asked to verify the sendmail flags (if there
1032are any) before the mail is sent.
1033Address matching is case insensitive and done from most specific to
1034least.
1035.Pp
1036For example if
1037you have:
1038.Bd -literal -offset indent
1039smopts mylist -F "List Maintainer"
1040smopts @NetBSD.org -f anon@somewhere.net -F "Anon Ymous"
1041smopts friend@NetBSD.org ""
1042.Ed
1043.Pp
1044then mail sent to any of the addresses that the
1045.Ql mylist
1046alias expands to would have the sender's name set to
1047.Ql List Maintainer .
1048Mail sent to anyone at NetBSD.org other than
1049.Ql friend@NetBSD.org
1050would look like it was sent from
1051.Ql anon@somewhere.net
1052by
1053.Ql Anon Ymous .
1054Mail sent to
1055.Ql friend@NetBSD.org
1056would not have any sendmail flags set (unless they are set by the
1057.Ic \&~h
1058escape).
1059.It Ic sort
1060With no argument,
1061.Ic sort
1062does nothing.
1063Otherwise it will sort based on the header field name given as an
1064argument.
1065A few names are special:
1066.Bd -literal -offset indent
1067blines		sort based on the number of body lines.
1068hlines		sort on the number of header lines.
1069tlines		sort on the total number of lines.
1070size		sort on the message size
1071sday		sent day (ignores the hour/min/sec)
1072rday		received day (ignores the hour/min/sec)
1073sdate		sent date
1074rdate		received date
1075subject		sort on the subject, ignoring "Re:" prefixes.
1076from		sort on the sender's address.
1077.Ed
1078.Pp
1079The check for these special names is case sensitive while the header
1080field name comparisons are case insensitive, so changing the case on
1081any of these special names will sort based on the header field
1082ignoring the special keyword.
1083.Pp
1084There are also three modifiers which may precede the argument:
1085.Bd -literal -offset indent
1086\&!	reverse the sorting order.
1087\&^	case insensitive sorting.
1088\&-	skin the field (removing RFC 822 comments and
1089	keep the address).
1090.Ed
1091.Pp
1092The same keywords and modifiers also apply to threading.
1093(See the
1094.Ic thread
1095command.)
1096.Pp
1097Note:
1098.Ic sort
1099has no effect on the threading, sorting only on the heads
1100of the threads if threads exist.
1101.Pp
1102.It Ic source
1103The
1104.Ic source
1105command reads commands from a file.
1106.It Ic tag
1107Tag a list of messages or the current message if none are given.
1108In hidden thread mode, the entire thread will be tagged, i.e.,
1109.Ic tag
1110is recursive
1111.It Ic tagbelow
1112Tag all messages of the current thread below the level of the
1113current message (dot) or the supplied message number if given.
1114.It Ic thread
1115By default this threads the current message list based on the
1116.Ql In-Reply-To
1117and
1118.Ql References
1119header fields (intended for this purpose by RFC 2822).
1120If given an argument, it will thread on that header field name
1121instead.
1122The same field keywords and modifiers recognized by the sort command
1123are also recognized here.
1124Display of the threads is controlled by the
1125.Ic hide
1126and
1127.Ic expose
1128commands; navigation of threads is done with the
1129.Ic down ,
1130.Ic up ,
1131and
1132.Ic tset
1133commands.
1134.Pp
1135If
1136.Ar recursive-commands
1137is defined, many commands (e.g.,
1138.Ic print )
1139act on the entire thread (when it is hidden), otherwise they act on
1140just the current message.
1141.Pp
1142Note: the
1143.Ql In-Reply-To
1144and
1145.Ql Reference
1146header fields are necessary to do threading correctly.
1147This version of
1148.Nm
1149now emits these header fields when replying.
1150.It Ic top
1151Takes a message list and prints the top few lines of each.
1152The number of lines printed is controlled by the variable
1153.Ic toplines
1154and defaults to five.
1155.It Ic tset
1156Set the current thread (thread set) so that the supplied message
1157number (or the current message if no argument is given) is at the top
1158level of the current thread.
1159.It Ic type
1160.Pq Ic t
1161A synonym for
1162.Ic print .
1163.It Ic unalias
1164Takes a list of names defined by
1165.Ic alias
1166commands and discards the remembered groups of users.
1167The group names no longer have any significance.
1168.It Ic undelete
1169.Pq Ic u
1170Takes a message list and marks each message as
1171.Ic not
1172being deleted.
1173.It Ic unread
1174.Pq Ic unr
1175Takes a message list and marks each message as
1176.Em not
1177having been read.
1178.It Ic unset
1179Takes a list of option names and discards their remembered values;
1180the inverse of
1181.Ic set .
1182.It Ic unsmopts
1183Takes a list of
1184.Dq address-specs
1185defined by
1186.Ic smopts
1187commands and discards them from the smopts database.
1188.It Ic untag
1189Untag a list of messages or the current message if none are given.
1190Like the
1191.Ic tag
1192command,
1193.Ic untag
1194is recursive on hidden threads.
1195.It Ic unthread
1196Undo all threading and sorting, restoring the original display order,
1197i.e., the order in the mail file.
1198.It Ic up
1199Go up one level in the thread.
1200This also takes an optional (positive) argument to go up multiple
1201levels in the thread.
1202.It Ic view
1203.Pq Ic vie
1204Like
1205.Ic print
1206but has the opposite MIME decoding behavior.
1207(See the
1208.Ar mime-decode-message
1209variable.)
1210.It Ic visual
1211.Pq Ic v
1212Takes a message list and invokes the display editor on each message.
1213.It Ic write
1214.Pq Ic w
1215Similar to
1216.Ic save ,
1217except that
1218.Em only
1219the message body
1220.Em ( without
1221the header) is saved.
1222Extremely useful for such tasks as sending and receiving source
1223program text over the message system.
1224.It Ic xit
1225.Pq Ic x
1226A synonym for
1227.Ic exit .
1228.It Ic z
1229.Nm
1230presents message headers in windowfuls as described under the
1231.Ic headers
1232command.
1233You can move
1234.Nm Ns Ap s
1235attention forward to the next window with the
1236.Ic \&z
1237command.
1238Also, you can move to the previous window by using
1239.Ic \&z\&\- .
1240.El
1241.Ss Tilde/Escapes
1242Here is a summary of the tilde escapes, which are used when composing
1243messages to perform special functions.
1244Tilde escapes are only recognized at the beginning of lines.
1245The name
1246.Dq Em tilde\ escape
1247is somewhat of a misnomer since the actual escape character can be set
1248by the option
1249.Ic escape .
1250.Bl -tag -width Ds
1251.It Ic \&~! Ns Ar command
1252Execute the indicated shell command, then return to the message.
1253.It Ic \&~@ Op Ar filelist
1254Add the files in the white-space delimited
1255.Ar filelist
1256to the attachment list.
1257If
1258.Ar filelist
1259is omitted, edit the attachment list, possibly appending to it: For
1260each file in the list the user is prompted to change its attachment
1261data.
1262Changing the filename to empty will delete it from the list.
1263Upon reaching the end of the attachment list, the user is prompted for
1264additional files to attach until an empty filename is given.
1265Filenames containing white-space can only be added in this
1266.Dq edit
1267mode.
1268.It Ic \&~a
1269Inserts the autograph string from the sign= option into the message.
1270.It Ic \&~A
1271Inserts the autograph string from the Sign= option into the message.
1272.It Ic \&~b Ns Ar name ...
1273Add the given names to the list of carbon copy recipients but do not make
1274the names visible in the Cc: line
1275.Dq ( blind
1276carbon copy).
1277.It Ic \&~c Ns Ar name ...
1278Add the given names to the list of carbon copy recipients.
1279.It Ic \&~d
1280Read the file
1281.Dq Pa dead.letter
1282from your home directory into the message.
1283.It Ic \&~e
1284Invoke the text editor on the message collected so far.
1285After the editing session is finished, you may continue appending
1286text to the message.
1287.It Ic \&~f Ns Ar messages
1288Read the named messages into the message being sent.
1289If no messages are specified, read in the current message.
1290Message headers currently being ignored (by the
1291.Ic ignore
1292or
1293.Ic retain
1294command) are not included.
1295.It Ic \&~F Ns Ar messages
1296Identical to
1297.Ic \&~f ,
1298except all message headers are included.
1299.It Ic \&~h
1300Edit the message header fields, and the options passed to sendmail (the
1301.Li Smopts ) ,
1302by typing each one in turn and allowing the user to append text to the
1303end or modify the field by using the current terminal erase and kill
1304characters.
1305If
1306.Xr editline 3
1307support is included, then that line editor is used.
1308.It Ic \&~i Ns Ar string
1309Inserts the value of the named option into the text of the message.
1310.It Ic \&~m Ns Ar messages
1311Read the named messages into the message being sent, indented by a
1312tab or by the value of
1313.Ar indentprefix .
1314If no messages are specified, read the current message.
1315Message headers currently being ignored (by the
1316.Ic ignore
1317or
1318.Ic retain
1319command) are not included.
1320.It Ic \&~M Ns Ar messages
1321Identical to
1322.Ic \&~m ,
1323except all message headers are included.
1324.It Ic \&~p
1325Print out the message collected so far, prefaced by the message header
1326fields.
1327.It Ic \&~q
1328Abort the message being sent, copying the message to
1329.Dq Pa dead.letter
1330in your home directory if
1331.Ic save
1332is set.
1333.It Ic \&~x
1334Exits as with \&~q, except the message is not saved in
1335.Dq Pa dead.letter .
1336.It Ic \&~r Ns Ar filename
1337.It Ic \&~\*[Lt] Ns Ar filename
1338Reads the named file into the message.
1339If the argument begins with
1340.Ql \&! ,
1341the rest of the string is taken as an arbitrary system command and is
1342executed, with the standard output inserted into the message.
1343.It Ic \&~s Ns Ar string
1344Cause the named string to become the current subject field.
1345.It Ic \&~\&t Ns Ar name ...
1346Add the given names to the direct recipient list.
1347.It Ic \&~\&v
1348Invoke an alternative editor (defined by the
1349.Ev VISUAL
1350option) on the message collected so far.
1351Usually, the alternative editor will be a screen editor.
1352After you quit the editor, you may resume appending
1353text to the end of your message.
1354.It Ic \&~w Ns Ar filename
1355Write the message onto the named file.
1356.It Ic \&~\&| Ns Ar command
1357Pipe the message body through the command as a filter.
1358If the command gives no output or terminates abnormally, retain the
1359original text of the message.
1360The command
1361.Xr fmt 1
1362is often used as
1363.Ic command
1364to rejustify the message.
1365.It Ic \&~: Ns Ar mail-command
1366Execute the given mail command.
1367Not all commands, however, are allowed.
1368.It Ic \&~~ Ns Ar string
1369Insert the string of text in the message prefaced by a single ~.
1370If you have changed the escape character, then you should double
1371that character in order to send it.
1372.El
1373.Ss Mail Options
1374Options are controlled via
1375.Ic set
1376and
1377.Ic unset
1378commands.
1379Options may be either binary, in which case it is only
1380significant to see whether they are set or not; or string, in which
1381case the actual value is of interest.
1382The binary options include the following:
1383.Bl -tag -width append
1384.It Ar append
1385Causes messages saved in
1386.Ar mbox
1387to be appended to the end rather than prepended.
1388This should always be set (perhaps in
1389.Pa /etc/mail.rc ) .
1390.It Ar ask , Ar asksub
1391Causes
1392.Nm
1393to prompt you for the subject of each message you send.
1394If you respond with simply a newline, no subject field will be sent.
1395.It Ar askcc
1396Causes you to be prompted for additional carbon copy recipients at
1397the end of each message.
1398Responding with a newline indicates your
1399satisfaction with the current list.
1400.It Ar autoinc
1401Causes new mail to be automatically incorporated when it arrives.
1402Setting this is similar to issuing the
1403.Ic inc
1404command at each prompt, except that the current message is not
1405reset when new mail arrives.
1406.It Ar askbcc
1407Causes you to be prompted for additional blind carbon copy recipients
1408at the end of each message.
1409Responding with a newline indicates your
1410satisfaction with the current list.
1411.It Ar autoprint
1412Causes the
1413.Ic delete
1414command to behave like
1415.Ic dp
1416\- thus, after deleting a message, the next one will be typed
1417automatically.
1418.It Va crt
1419If
1420.Va crt
1421is set, then the
1422.Ev PAGER
1423will be used for the
1424.Ic print ,
1425.Ic Print ,
1426.Ic type ,
1427and
1428.Ic Type
1429commands.
1430Normally these commands do not invoke the pager.
1431.It Ar debug
1432Setting the binary option
1433.Ar debug
1434is the same as specifying
1435.Fl d
1436on the command line and causes
1437.Nm
1438to output all sorts of information useful for debugging
1439.Nm .
1440.It Ar dot
1441The binary option
1442.Ar dot
1443causes
1444.Nm
1445to interpret a period alone on a line as the terminator
1446of a message you are sending.
1447.It Ar enable-pipes
1448If defined, the output of most commands can be piped into a shell
1449command or redirected to a file.
1450The pipe/redirection is signaled by the first occurrence of a
1451.Ql |
1452or
1453.Ql \*[Gt]
1454character that is not in a quoted string or in a parenthetical
1455group.
1456This character terminates the mail command line and the remaining
1457string is passed to the shell.
1458For example, assuming normal headers, something like
1459.Bd -literal -offset indent
1460  from john@ | fgrep -i ' "Re:' | wc
1461.Ed
1462.Pp
1463could be used to count how may replies were made by senders with
1464.Ql john@
1465in their address and
1466.Bd -literal -offset indent
1467  from john@ \*[Gt]\*[Gt] /tmp/john
1468.Ed
1469.Pp
1470would append all the headers from such senders to /tmp/john.
1471.Pp
1472Note: With piping enabled, you cannot use the
1473.Ql \&|
1474as a logical
1475.Dq or
1476operator outside of a parenthetical group.
1477This should not be a problem as it is the default logical operator.
1478(See the
1479.Sx Specifying messages
1480section.)
1481.It Ar hold
1482This option is used to hold messages in the system mailbox
1483by default.
1484.It Ar ignore
1485Causes interrupt signals from your terminal to be ignored and echoed as
1486@'s.
1487.It Ar metoo
1488Usually, when a group is expanded that contains the sender, the sender
1489is removed from the expansion.
1490Setting this option causes the sender to be included in the group.
1491.It Ar mime-attach-list
1492If set, the command line flag
1493.Fl a
1494will accept a whitespace delimited list of files.
1495Otherwise, its argument is interpreted as a single filename.
1496Warning: If enabled, care must be taken to properly quote files that
1497contain whitespace, both from the shell and from this second expansion
1498done by
1499.Nm .
1500.It Ar mime-decode-header
1501If set, decode the headers along with the body when
1502.Ar mime-decode-message
1503is set.
1504The header decode follows the same rules as the body (see
1505.Ar mime-decode-message ) .
1506.It Ar mime-decode-insert
1507When inserting
1508a message into the mail buffer
1509.Po Ic \&~f
1510or
1511.Ic \&~F
1512.Pc ,
1513the text inserted will be decoded according to the settings of the
1514.Ar mime-decode-message
1515and
1516.Ar mime-decode-header
1517variables.
1518.It Ar mime-decode-message
1519If set, the
1520.Ic More ,
1521.Ic more ,
1522.Ic Page ,
1523.Ic page ,
1524.Ic Print ,
1525.Ic print ,
1526.Ic Type ,
1527and
1528.Ic type
1529commands will display decoded the MIME messages.
1530Otherwise, they display the undecoded message.
1531Recall that the
1532.Ic View
1533and
1534.Ic view
1535commands always have the opposite MIME decoding behavior from these
1536commands.
1537.It Ar mime-decode-quote
1538When quoting
1539a message into the mail buffer
1540.Po Ic \&~m
1541or
1542.Ic \&~M
1543.Pc ,
1544the text inserted will be decoded according to the settings of the
1545.Ar mime-decode-message
1546and
1547.Ar mime-decode-header
1548variables.
1549.It Ar mime-detach-batch
1550If set, the detach command does not prompt for anything
1551.Po unless
1552.Ar mime-detach-overwrite
1553is set to
1554.Ql ask
1555.Pc ,
1556overwriting target files depending on the setting of
1557.Ar mime-detach-overwrite .
1558.It Ar noheader
1559Setting the option
1560.Ar noheader
1561is the same as giving the
1562.Fl N
1563flag on the command line.
1564.It Ar nosave
1565Normally, when you abort a message with two
1566.Tn RUBOUT
1567(erase or delete)
1568.Nm
1569copies the partial letter to the file
1570.Dq Pa dead.letter
1571in your home directory.
1572Setting the binary option
1573.Ar nosave
1574prevents this.
1575.It Ar quiet
1576Suppresses the printing of the version when first invoked.
1577.It Ar recursive-commands
1578When defined, and threading is in effect, the following commands
1579operate on the entire thread (if it is
1580.Dq hidden )
1581rather than just the top displayed message of the thread:
1582.Bd -literal -offset indent
1583More Page Print Type View more page print type view
1584top
1585Save copy save write
1586Detach detach
1587delete dp dt
1588undelete
1589hold preserve
1590mbox mkread touch unread
1591tag untag invtags
1592.Ed
1593.Pp
1594If not defined, or if the threads are
1595.Dq exposed ,
1596commands behave exactly as they do in non-threaded mode, i.e., each
1597operates on individual messages.
1598.It Ar Replyall
1599Reverses the sense of
1600.Ic reply
1601and
1602.Ic Reply
1603commands.
1604.It Ar searchheaders
1605If this option is set, then a message-list specifier in the form
1606.Dq /x:y
1607will expand to all messages containing the substring
1608.Dq y
1609in the header field
1610.Dq x .
1611The string search is case insensitive.
1612If
1613.Dq x
1614is omitted, it will default to the
1615.Ql Subject
1616header field.
1617If
1618.Dq y
1619is omitted, only those messages that contain the field
1620.Dq x
1621will be matched.
1622The three forms
1623.Dq /from:y ,
1624.Dq /to:y ,
1625and
1626.Dq /body:y
1627are special.
1628The first will match all messages which contain the substring
1629.Dq y
1630in the headline (which is added locally at receipt time and begins
1631with
1632.Dq From \& ) .
1633The second will match all messages containing the substring
1634.Dq y
1635in the
1636.Ql To ,
1637.Ql Cc ,
1638or
1639.Ql Bcc
1640header fields.
1641The third will match all messages which contain the substring
1642.Dq y
1643in a line of the message body.
1644The check for
1645.Dq from ,
1646.Dq to ,
1647and
1648.Dq body
1649is case sensitive, so that
1650.Dq /From:y
1651and
1652.Dq /To:y
1653can be used to search the
1654.Ql From
1655and
1656.Ql To
1657fields, respectively.
1658(See also
1659.Ar "regex-search" . )
1660.It Ar smopts-verify
1661Verify the sendmail options used on outgoing mail if they were obtained from a
1662.Ar smopts
1663match.
1664This has no effect if there are no sendmail flags or if the flags
1665were set by the
1666.Ic \&~h
1667escape.
1668.It Ar verbose
1669Setting the option
1670.Ar verbose
1671is the same as using the
1672.Fl v
1673flag on the command line.
1674When mail runs in verbose mode, the actual delivery of messages is
1675displayed on the user's terminal.
1676.El
1677.Ss Option String Values
1678.Bl -tag -width Va
1679.It Ev EDITOR
1680Pathname of the text editor to use in the
1681.Ic edit
1682command and
1683.Ic \&~e
1684escape.
1685If not defined, then a default editor is used.
1686.It Ev LISTER
1687Pathname of the directory lister to use in the
1688.Ic folders
1689command.
1690Default is
1691.Pa /bin/ls .
1692.It Ev PAGER
1693Pathname of the program to use in the
1694.Ic more
1695command or when
1696.Ic crt
1697variable is set.
1698The default paginator
1699.Xr more 1
1700is used if this option is not defined.
1701.It Ev SHELL
1702Pathname of the shell to use in the
1703.Ic \&!
1704command and the
1705.Ic \&~!
1706escape.
1707A default shell is used if this option is not defined.
1708.It Ev VISUAL
1709Pathname of the text editor to use in the
1710.Ic visual
1711command and
1712.Ic \&~v
1713escape.
1714.It Ar el-completion-keys
1715A comma or space delimited list of keys to do
1716.Xr editline 3
1717completion.
1718For example
1719.Nm set el-completion-keys=^I,^D
1720will bind completion to both the tab and CTRL-D keys.
1721(Requires
1722.Xr editline 3
1723support.)
1724.It Ar el-editor
1725The line editing mode: must be
1726.Ql emacs
1727or
1728.Ql vi .
1729If unset, editing is not enabled.
1730(Requires
1731.Xr editline 3
1732support.)
1733.It Ar el-history-size
1734The number of lines of history to remember.
1735If unset, history is not enable.
1736(Requires
1737.Xr editline 3
1738support.)
1739.It Ar escape
1740If defined, the first character of this option gives the character to
1741use in the place of
1742.Ic \&~
1743to denote escapes.
1744.It Ar folder
1745The name of the directory to use for storing folders of
1746messages.
1747If this name begins with a
1748.Ql / ,
1749.Nm
1750considers it to be an absolute pathname; otherwise, the
1751folder directory is found relative to your home directory.
1752.It Ar header-format
1753If set, use this format string when displaying headers in command
1754mode.
1755The format string supports the following conversions in addition to
1756those of
1757.Xr strftime 3 :
1758.Pp
1759.Bl -tag -width ".Ar \&%?key?" -compact
1760.It Ar \&%?key?
1761The header field with name
1762.Ql key .
1763Note: if key[0] is
1764.Ql \&- ,
1765ignore the
1766.Ql \&-
1767and extract the address
1768portion of the field (i.e.,
1769.Dq skin
1770the field).
1771.It Ar \&%?*string?
1772If the depth is
1773.Ar n ,
1774substitute
1775.Ql string
1776.Ar n
1777times.
1778This is intended to be used when displaying an
1779.Dq exposed thread .
1780.It Ar \&%?\*[Am]string?
1781Like
1782.Ar \&%?*string? ,
1783but uses the depth relative to the current depth rather than the
1784absolute depth.
1785.It Ar \&%J
1786The number of header lines in the message.
1787.It Ar \&%K
1788The number of body lines in the message.
1789.It Ar \&%L
1790The total number of lines in the message.
1791.It Ar \&%N
1792The sender's full name (as in the
1793.Ql From
1794or
1795.Ql Sender
1796fields).
1797.It Ar \&%O
1798The message size.
1799.It Ar \&%P
1800The current
1801.Dq dot
1802.Pq Sq \*[Gt]
1803message.
1804.It Ar \&%Q
1805The message status flag.
1806.It Ar \&%Z
1807The time zone name (if it exists).
1808.It Ar \&%f
1809The email address of sender.
1810.It Ar \&%i
1811The message number.
1812.It Ar \&%n
1813The sender's login name (taken from the address).
1814.It Ar \&%q
1815The subject.
1816.It Ar \&%t
1817The total number of messages.
1818.It Ar \&%z
1819The GMT offset (if found).
1820.El
1821.Pp
1822If the format string begins with
1823.Ql "\&%??"
1824then the date will be extracted from the headline.
1825Otherwise it will be extracted from the
1826.Ql Date
1827header falling back to the headline if that extraction fails.
1828For example, the default format is:
1829.Bd -literal -offset 0
1830set header-format=\&"\&%??%P%Q%?* ?%3i \&%-21.20f \&%a \&%b \&%e \&%R \&%3K/%-5O \&\\"%q\\""
1831.Ed
1832.Pp
1833Note 1: The message status flag
1834.Ql \&%Q
1835will display the single character
1836.Ql \+
1837for the parent of a subthread.
1838This will be overwritten by a
1839.Ql T ,
1840.Ql E ,
1841.Ql \&* ,
1842.Ql P ,
1843.Ql U ,
1844.Ql N ,
1845.Ql M
1846indicating, respectively, a tagged, modified, saved, preserved,
1847unread, new, or modified message, in that order with the last matching
1848condition being the one displayed.
1849In the case of hidden threads, the entire subthread is searched and
1850the letters above will be displayed in lower case if the property is
1851that of a hidden child with the case
1852.Ql \&*
1853being displayed as
1854.Ql \*[Am] .
1855.Pp
1856Note 2:
1857.Ar \&%n
1858and
1859.Ar \&%t
1860as used by
1861.Xr strftime 3
1862were redundant with \\t and \\n, respectively, so nothing is lost
1863using them here.
1864.It Ar ignoreeof
1865An option related to
1866.Ar dot
1867is
1868.Ar ignoreeof
1869which makes
1870.Nm
1871refuse to accept a
1872.Ql control-D
1873as the end of a message.
1874If given a numeric argument
1875.Ar n ,
1876a
1877.Ql control-D
1878will be accepted after
1879.Ar n
1880tries.
1881.Ar Ignoreeof
1882also applies to
1883.Nm
1884command mode.
1885.It Ar indentpreamble
1886If set, this format string will be inserted before quoting a message
1887.Po Ic \&~m
1888or
1889.Ic \&~M
1890.Pc .
1891The format syntax is the same as for
1892.Ar header-format .
1893For example, the following:
1894.Bd -literal -offset 0
1895set indentpreamble=
1896  \&"On \&%b \&%e \&%T, \&%Y \&%z (%Z), \&%n (%.50N) wrote:\\n-- Subject: \&%.65q\\n"
1897.Ed
1898.Pp
1899would insert something like
1900.Bd -literal -offset 0
1901On Oct 27 11:00:07, 2006 -0400 (EDT), anon (Anon Ymous) wrote:
1902-- Subject: suggestions for mail(1)
1903.Ed
1904.Pp
1905before the quoted message.
1906.It Ar indentprefix
1907String used by the
1908.Ic ~m
1909and
1910.Ic ~M
1911tilde escapes for indenting messages, in place of
1912the normal tab character
1913.Pq Sq ^I .
1914Be sure to quote the value if it contains
1915spaces or tabs.
1916.It Ar indentpostscript
1917If set, this format string will be inserted after quoting a message
1918.Po Ic \&~m
1919or
1920.Ic \&~M
1921.Pc .
1922The format syntax is the same as for
1923.Ar header-format .
1924For example, the following:
1925.Bd -literal -offset 0
1926set indentpostscript="-- End of excerpt from \&%.50N"
1927.Ed
1928.Pp
1929would insert something like
1930.Bd -literal -offset 0
1931-- End of excerpt from Anon Ymous
1932.Ed
1933.Pp
1934after the quoted message.
1935.It Ar mime-body-TYPE-SUBTYPE
1936MIME-hook for the body of a MIME block of
1937.Ql "Content-Type: TYPE/SUBTYPE" .
1938(See
1939.Sy MIME Enhancements
1940below.)
1941.It Ar mime-charset
1942Convert
1943.Ql "Content-type: text"
1944messages to this character set or
1945.Ql us-ascii
1946if the value is empty.
1947If unset, no character set conversion is done.
1948.It Ar mime-detach-dir
1949The directory to detach files to if the
1950.Ar detach
1951command is given no arguments.
1952(See
1953.Ar detach . )
1954.It Ar mime-detach-overwrite
1955This controls overwriting of existing files by the detach command.
1956If set to
1957.Ql ask
1958the user will be prompted before overwriting a file.
1959If set to
1960.Ql yes ,
1961or to the empty string, existing target files will be overwritten.
1962If set to
1963.Ql no ,
1964no target files will be overwritten.
1965.It Ar mime-encode-message
1966If set, encode the body of the message as required.
1967Typically, this is just an issue of whether
1968.Ql quoted-printable
1969encoding is used or not.
1970If it has a value, then use it to determine the encoding type.
1971Allowed values are
1972.Ql 7bit ,
1973.Ql 8bit ,
1974.Ql binary ,
1975.Ql quoted-printable ,
1976or
1977.Ql base64 .
1978.It Ar mime-head-TYPE-SUBTYPE
1979MIME-hook for the header of a MIME block of
1980.Ql "Content-Type: TYPE/SUBTYPE" .
1981(See
1982.Sy MIME Enhancements
1983below.)
1984.It Ar mime-hook-TYPE-SUBTYPE
1985MIME-hook for MIME block of
1986.Ql "Content-Type: TYPE/SUBTYPE" .
1987(See
1988.Sy MIME Enhancements
1989below.)
1990.It Ev MBOX
1991The name of the
1992.Ar mbox
1993file.
1994It can be the name of a folder.
1995The default is
1996.Dq Li mbox
1997in the user's home directory.
1998.It Ar prompt
1999If defined, it specifies the prompt to use when in command mode.
2000Otherwise, the default
2001.Ql \*[Am]
2002is used.
2003The format syntax is the same as for
2004.Ar header-format .
2005.It Ar record
2006If defined, gives the pathname of the file used to record all outgoing
2007mail.
2008If not defined, then outgoing mail is not so saved.
2009.It Ar regex-search
2010If set, regular expression searches are used, instead of simple case
2011insensitive substring matches, when determining message lists by
2012searching sender names, subjects, or header fields (if
2013.Ar searchheaders
2014is defined); see the
2015.Sx Specifying message
2016section.
2017The value of the variable is a space or comma delimited list of
2018options.
2019Valid options are
2020.Ql icase
2021to do case insensitive searches,
2022.Ql extended
2023to use extended (rather than basic) regular expressions, and
2024.Ql nospec
2025to turn off all special character meanings and do literal string
2026searches.
2027Note that
2028.Ql extended
2029and
2030.Ql nospec
2031are not compatible (see
2032.Xr regcomp 3 ) .
2033.It Ar ReplyAsRecipient
2034This is used when replying to email (see the
2035.Ic reply
2036or
2037.Ic Reply
2038commands).
2039It is useful if you have multiple email addresses and wish to ensure
2040that replies respect them.
2041If set, grab the email address(es) from the
2042.Ql To
2043field of the message being replied to.
2044If there is only one such address, and if it does not match any
2045address in the value of
2046.Ar ReplyAsRecipient
2047(a comma or space delimited list of addresses, possibly empty), then
2048use this address in the
2049.Ql From
2050field of the reply.
2051This is accomplished by passing the address to
2052.Xr sendmail 1
2053with the
2054.Fl f
2055option.
2056Note: the sendmail options can be edited with the
2057.Ic \&~h
2058escape.
2059(See also the
2060.Ic smopts
2061command.)
2062.It Ar toplines
2063If defined, gives the number of lines of a message to be printed out
2064with the
2065.Ic top
2066command; normally, the first five lines are printed.
2067.El
2068.Ss MIME Enhancements
2069A MIME message is (recursively) divided into a series of MIME parts
2070that can be thought of as sub-messages, each with a header and body.
2071When MIME support is enabled (by setting
2072.Ar mime-decode-message ) ,
2073.Nm
2074splits a message into a series of its smallest MIME parts and
2075processes those parts as if they were messages themselves, passing the
2076header and body through a pipeline of the form:
2077.Pp
2078.Dl mail -\*[Gt] MIME-decoder -\*[Gt] MIME-hook -\*[Gt] pager -\*[Gt] screen
2079.Pp
2080The
2081.Em MIME-decoder
2082decodes
2083.Ql base64
2084or
2085.Ql quoted-printable
2086encoding and is enabled according to the
2087.Ql Content-Transfer-Encoding
2088of the part.
2089The
2090.Em MIME-hook
2091is an external program to further process the part (see below).
2092The
2093.Em pager
2094is the program that pages the message
2095(see
2096.Ev PAGER ) .
2097Any of these intermediate pipe stages may be missing and/or different
2098for the head and body of each MIME part.
2099Certain
2100.Ql Content-Types
2101may disable the entire pipeline (e.g.,
2102.Ql application/octet ) .
2103.Pp
2104The
2105.Em MIME-hook
2106stage is not present unless one of the following variables is set:
2107.Bd -literal -offset indent
2108mime-hook-TYPE-SUBTYPE    applies to the entire MIME part
2109mime-head-TYPE-SUBTYPE    applies to the header of the MIME part
2110mime-body-TYPE-SUBTYPE    applies to the body of the MIME part
2111.Ed
2112.Pp
2113where TYPE and SUBTYPE are the
2114.Ql Content-Type
2115type and subtype
2116(respectively) of the MIME part to which the hook applies.
2117If the
2118.Dq -SUBTYPE
2119is missing, any subtype is matched.
2120The value of these variables has the format:
2121.Bd -filled -offset indent
2122.Op Ar flags
2123.Ar command
2124.Ed
2125.Pp
2126where the
2127.Ar command
2128is expected to read from stdin and write to stdout, and the possible
2129flags are
2130.Bl -tag -width Ds -offset indent
2131.It !
2132Execute
2133.Ar command
2134in a sub-shell rather than doing an
2135.Xr exec 3
2136(see
2137.Va SHELL ) .
2138.It +
2139Use this hook when selecting the part to display in a
2140.Ql multipart/alternative
2141block.
2142Multipart blocks contain
2143.Dq alternative
2144versions with the same information, in increasing order of preference
2145(and decoding complexity).
2146The last one the mail agent understands is the one to be displayed.
2147This is typically used for sending a message in both
2148.Dq plain text
2149and
2150.Dq html ,
2151but more complex subtypes are also possible.
2152.It -
2153Do not decode before executing
2154.Ar command .
2155.El
2156.Pp
2157If your
2158.Ar command
2159begins with one of these flags, precede it with a space to signal the
2160end of the flags.
2161.Pp
2162WARNING: automatically running a program is a potential security risk
2163if that program has bugs, so be careful what you run.
2164.Pp
2165.Em Examples :
2166View all
2167.Ql "Content-Type: image/jpeg"
2168parts with
2169.Xr xv 1
2170(assuming it is installed):
2171.Pp
2172.Dl set mime-body-image-jpeg="/usr/pkg/bin/xv -"
2173.Pp
2174Decode all
2175.Ql "Content-Type: images/*"
2176blocks with
2177.Xr uudeview 1
2178(assuming it is installed), placing the results in
2179.Pa /tmp :
2180.Pp
2181.Dl set mime-hook-image="-/usr/pkg/bin/uudeview -p /tmp -i -a +o -q -"
2182.Pp
2183Read all
2184.Ql "Content-Type: text/html"
2185parts using
2186.Xr lynx 1
2187(assuming it is installed) and add this support to
2188.Ql multipart/alternative
2189blocks:
2190.Pp
2191.Bd -literal -offset indent
2192set mime-body-text-html="+/usr/pkg/bin/lynx -force_html -dump -stdin"
2193.Ed
2194.Sh ENVIRONMENT
2195.Nm
2196uses the
2197.Ev HOME ,
2198.Ev TMPDIR ,
2199and
2200.Ev USER
2201environment variables.
2202.Sh FILES
2203.Bl -tag -width /usr/share/misc/mail.*help -compact
2204.It Pa /var/mail/*
2205Post office.
2206.It ~/mbox
2207User's old mail.
2208.It ~/.mailrc
2209File giving initial mail commands.
2210This can be overridden by setting the
2211.Ev MAILRC
2212environment variable.
2213.It Pa /tmp/mail.R*
2214Temporary files.
2215.It Pa /usr/share/misc/mail.*help
2216Help files.
2217.It Pa /etc/mail.rc
2218System initialization file.
2219.El
2220.Sh SEE ALSO
2221.Xr fmt 1 ,
2222.Xr newaliases 1 ,
2223.Xr sendmail 1 ,
2224.Xr vacation 1 ,
2225.Xr aliases 5 ,
2226.Xr mailaddr 7
2227and
2228.Rs
2229.%T "The Mail Reference Manual"
2230.Re
2231.Sh HISTORY
2232A
2233.Nm
2234command
2235appeared in
2236.At v6 .
2237This man page is derived from
2238.%T "The Mail Reference Manual"
2239originally written by Kurt Shoens.
2240.Sh BUGS
2241There are some flags and commands that are not documented here.
2242Most are not useful to the general user.
2243.Pp
2244Usually,
2245.Nm
2246is just a link to
2247.Nm Mail ,
2248which can be confusing.
2249.Pp
2250The name of the
2251.Ic alternates
2252list is incorrect English (it should be
2253.Dq alternatives ) ,
2254but is retained for compatibility.
2255.Pp
2256There must be sufficient space on $TMPDIR for various temporary files.
2257.Pp
2258If an unrecoverable character set conversion error occurs (during
2259display), the message is truncated and a warning is printed.
2260This seems to be rare, but probably the remainder of the message
2261should be printed without conversion.
2262.Pp
2263The internal sh-like parser is not terribly sh-like.
2264.Pp
2265Selecting messages by their content (i.e., with
2266.Ql /body: )
2267is rather slow.
2268