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