check for overflow in getrawlist()
[unix-history] / usr / src / usr.bin / mail / mail.1
CommitLineData
91d7df00
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
cb530a2d 5.\" @(#)mail.1 6.4 (Berkeley) %G%
91d7df00 6.\"
bb04cec6 7.TH MAIL 1 ""
91d7df00
KM
8.UC 4
9.SH NAME
10mail \- send and receive mail
11.SH SYNOPSIS
12.B mail
13[
dcee403d
KM
14.B \-v
15]
16[
17.B \-i
18]
19[
20.B \-n
21]
22[
23.B \-s
24subject
25]
26[
27user ...
28]
29.br
30.B mail
31[
32.B \-v
33]
34[
35.B \-i
36]
37[
38.B \-n
39]
91d7df00
KM
40.B \-f
41[
42name
43]
dcee403d
KM
44.br
45.B mail
46[
47.B \-v
91d7df00
KM
48]
49[
dcee403d 50.B \-i
91d7df00 51]
dcee403d
KM
52[
53.B \-n
54]
55.B \-u
56user
91d7df00
KM
57.SH INTRODUCTION
58.I Mail
59is a intelligent mail processing system, which has
60a command syntax reminiscent of
61.I ed
62with lines replaced by messages.
63.PP
dcee403d
KM
64The
65.B \-v
66flag puts mail into verbose mode; the details of
67delivery are displayed on the users terminal.
68The
69.B \-i
70flag causes tty interrupt signals to be ignored. This is
71particularly useful when using
72.I mail
73on noisy phone lines.
74The
75.B \-n
76flag inhibits the reading of /usr/lib/Mail.rc.
77.PP
91d7df00
KM
78.I "Sending mail.\ "
79To send a message to one or more other people,
80.I mail
81can be invoked with arguments which are the names of people to
82send to. You are then expected to type in your message, followed
83by an \s-2EOT\s0 (control\-D) at the beginning of a line.
dcee403d
KM
84A subject may be specified on the command line by using the
85.B \-s
86flag. (Only the first argument after the
87.B \-s
88flag is used as a subject; be careful to quote subjects
89containing spaces.)
91d7df00
KM
90The section below, labeled
91.I "Replying to or originating mail,"
92describes some features of
93.I mail
94available to help you compose your letter.
95.PP
96.I "Reading mail.\ "
dcee403d 97In normal usage
91d7df00
KM
98.I mail
99is given no arguments and checks your mail out of the
100post office, then
dcee403d 101prints out a one line header of each message there.
91d7df00
KM
102The current message is initially the first message (numbered 1)
103and can be printed using the
104.B print
105command (which can be abbreviated \fBp\fR).
106You can move among the messages much as you move between lines in
dcee403d 107.IR ed ,
91d7df00 108with the commands `+' and `\-' moving backwards and forwards, and
dcee403d 109simple numbers.
91d7df00
KM
110.PP
111.I "Disposing of mail.\ "
112After examining a message you can
113.B delete
114(\fBd\fR)
115the message or
116.B reply
117(\fBr\fR)
118to it.
119Deletion causes the
120.I mail
121program to forget about the message.
dcee403d 122This is not irreversible; the message can be
91d7df00
KM
123.B undeleted
124(\fBu\fR)
125by giving its number, or the
126.I mail
127session can be aborted by giving the
128.B exit
129(\fBx\fR)
130command.
131Deleted messages will, however, usually disappear never to be seen again.
132.PP
133.I "Specifying messages.\ "
134Commands such as
135.B print
136and
137.B delete
dcee403d 138can be given a list of message numbers as arguments to apply
91d7df00
KM
139to a number of messages at once.
140Thus ``delete 1 2'' deletes messages 1 and 2, while ``delete 1\-5''
141deletes messages 1 through 5.
142The special name ``*'' addresses all messages, and ``$'' addresses
143the last message; thus the command
144.B top
145which prints the first few lines of a message could be used in
146``top *'' to print the first few lines of all messages.
147.PP
148.I "Replying to or originating mail.\ "
149You can use the
150.B reply
151command to
152set up a response to a message, sending it back to the
153person who it was from.
dcee403d
KM
154Text you then type in, up to an end-of-file,
155defines the contents of the message.
91d7df00
KM
156While you are composing a message,
157.I mail
158treats lines beginning with the character `~' specially.
159For instance, typing ``~m'' (alone on a line) will place a copy
160of the current message into the response right shifting it by a tabstop.
161Other escapes will set up subject fields, add and delete recipients
162to the message and allow you to escape to an editor to revise the
163message or to a shell to run some commands. (These options
dcee403d 164are given in the summary below.)
91d7df00
KM
165.PP
166.I "Ending a mail processing session.\ "
167You can end a
168.I mail
169session with the
170.B quit
171(\fBq\fR)
172command.
173Messages which have been examined go to your
174.I mbox
175file unless they have been deleted in which case they are discarded.
176Unexamined messages go back to the post office.
177The
178.B \-f
179option causes
180.I mail
181to read in the contents of your
182.I mbox
183(or the specified file)
184for processing; when you
dcee403d 185.BR quit ,
91d7df00
KM
186.I mail
187writes undeleted messages back to this file.
dcee403d
KM
188The
189.B \-u
190flag is a short way of doing
191"mail
192.B \-f
193/usr/spool/mail/user".
91d7df00
KM
194.PP
195.I "Personal and systemwide distribution lists.\ "
196It is also possible to create a personal distribution lists so that,
197for instance, you can send mail to ``cohorts'' and have it go
198to a group of people.
199Such lists can be defined by placing a line like
200.IP
dcee403d 201alias cohorts bill ozalp jkf mark kridle@ucbcory
91d7df00
KM
202.PP
203in the file \&.mailrc in your home directory.
dcee403d 204The current list of such aliases can be displayed with the
91d7df00
KM
205.B alias
206.B (a)
207command in
dcee403d 208.IR mail .
91d7df00
KM
209System wide distribution lists can be created by editing
210/usr/lib/aliases, see
211.IR aliases (5)
212and
dcee403d
KM
213.IR sendmail (8);
214these are kept in a different syntax.
91d7df00
KM
215In mail you send, personal aliases will be expanded in mail sent
216to others so that they will be able to \fBreply\fR to the recipients.
217System wide \fIaliases\fR are not expanded when the mail is sent,
218but any reply returned to the machine will have the system wide
219alias expanded as all mail goes through
dcee403d 220.IR sendmail .
91d7df00
KM
221.PP
222.I "Network mail (ARPA, UUCP, Berknet)\ "
dcee403d
KM
223See
224.IR mailaddr(7)
225for a description of network addresses.
91d7df00
KM
226.PP
227.I Mail
dcee403d 228has a number of options which can be set in the
91d7df00
KM
229.I \&.mailrc
230file to alter its behavior; thus ``set askcc'' enables the ``askcc''
231feature. (These options are summarized below.)
232.SH SUMMARY
233(Adapted from the `Mail Reference Manual')
dcee403d 234.PP
91d7df00
KM
235Each command is typed on a line by itself, and may take arguments
236following the command word. The command need not be typed in its
237entirety \- the first command which matches the typed prefix is used.
dcee403d 238For commands which take message lists as arguments, if no message
91d7df00
KM
239list is given, then the next message forward which satisfies the
240command's requirements is used. If there are no messages forward of
241the current message, the search proceeds backwards, and if there are no
242good messages at all,
243.I mail
244types ``No applicable messages'' and
245aborts the command.
246.TP 12n
247.B \-
248Goes to the previous message and prints it out. If given a numeric
249argument
dcee403d 250.IR n ,
91d7df00 251goes to the
dcee403d 252.IR n -th
91d7df00
KM
253previous message and prints it.
254.TP
255.B ?
256Prints a brief summary of commands.
257.TP
258.B !
259Executes the \s-2UNIX\s0 shell command which follows.
260.TP
dcee403d
KM
261.B Print
262(\fBP\fR)
263Like
264.B print
265but also prints out ignored header fields. See also
266.B print
bb04cec6
KM
267,
268.B ignore
dcee403d 269and
bb04cec6 270.B retain.
dcee403d
KM
271.TP
272.B Reply
273(\fRR\fR)
274Reply to originator. Does not reply to other
275recipients of the original message.
276.TP
277.B Type
278(\fTT\fR)
279Identical to the
280.B Print
281command.
282.TP
91d7df00
KM
283.B alias
284(\fBa\fR) With no arguments, prints out all currently-defined aliases. With one
dcee403d
KM
285argument, prints out that alias. With more than one argument, creates
286an new or changes an on old alias.
287.TP
288.B alternates
289(\fBalt\fR)
290The
291.B alternates
292command is useful if you have accounts on several machines.
293It can be used to inform
294.I mail
295that the listed addresses are really you. When you
296.B reply
297to messages,
298.I mail
299will not send a copy of the message to any of the addresses
300listed on the
301.I alternates
302list. If the
303.B alternates
304command is given with no argument, the current set of alternate
305names is displayed.
91d7df00
KM
306.TP
307.B chdir
308(\fBc\fR) Changes the user's working directory to that specified, if given. If
309no directory is given, then changes to the user's login directory.
310.TP
dcee403d
KM
311.B copy
312(\fBco\fR)
313The
314.B copy
315command does the same thing that
316.B save
317does, except that it does not mark the messages it
318is used on for deletion when you quit.
319.TP
91d7df00
KM
320.B delete
321(\fBd\fR) Takes a list of messages as argument and marks them all as deleted.
322Deleted messages will not be saved in
dcee403d 323.IR mbox ,
91d7df00
KM
324nor will they be available for most other commands.
325.TP
326.B dp
327(also \fBdt\fR) Deletes the current message and prints the next message.
328If there is no next message,
329.I mail
330says ``at EOF.''
331.TP
332.B edit
333(\fBe\fR) Takes a list of messages and points the text editor at each one in
334turn. On return from the editor, the message is read back in.
335.TP
336.B exit
337(\fBex\fR or \fBx\fR) Effects an immediate return to the Shell without
338modifying the user's system mailbox, his
339.I mbox
340file, or his edit file in
dcee403d
KM
341.BR \-f .
342.TP
343.B file
344(\fBfi\fR)
345The same as
346.BR folder .
347.TP
348.B folders
349List the names of the folders in your folder directory.
350.TP
351.B folder
352(\fBfo\fR)
353The
354.B folder
355command switches to a new mail file or folder. With no
356arguments, it tells you which file you are currently reading.
357If you give it an argument, it will write out changes (such
358as deletions) you have made in the current file and read in
359the new file. Some special conventions are recognized for
360the name. # means the previous file, % means your system
361mailbox, %user means user's system mailbox, & means
362your \~/mbox file, and +folder means a file in your folder
363directory.
91d7df00
KM
364.TP
365.B from
366(\fBf\fR) Takes a list of messages and prints their message headers.
367.TP
368.B headers
369(\fBh\fR) Lists the current range of headers, which is an 18 message group. If
370a ``+'' argument is given, then the next 18 message group is printed, and if
371a ``\-'' argument is given, the previous 18 message group is printed.
372.TP
373.B help
374A synonym for ?
375.TP
376.B hold
377(\fBho\fR, also \fBpreserve\fR) Takes a message list and marks each
378message therein to be saved in the
379user's system mailbox instead of in
dcee403d 380.IR mbox .
91d7df00
KM
381Does not override the
382.B delete
383command.
384.TP
dcee403d 385.B ignore
bb04cec6
KM
386.B N.B.:
387.I Ignore
388has been superseded by
389.I retain.
390.br
dcee403d
KM
391Add the list of header fields named to the
392.IR "ignored list" .
393Header fields in the ignore list are not printed
394on your terminal when you print a message. This
395command is very handy for suppression of certain machine-generated
396header fields. The
397.B Type
398and
399.B Print
400commands can be used to print a message in its entirety, including
401ignored fields. If
402.B ignore
403is executed with no arguments, it lists the current set of
404ignored fields.
405.TP
91d7df00
KM
406.B mail
407(\fBm\fR) Takes as argument login names and distribution group names and sends
408mail to those people.
409.TP
dcee403d
KM
410.B mbox
411Indicate that a list of messages be sent to
412.I mbox
413in your home directory when you quit. This is the default
414action for messages if you do
415.I not
416have the
417.I hold
418option set.
419.TP
91d7df00
KM
420.B next
421(\fBn\fR like \fB+\fR or CR) Goes to the next message in sequence and types it.
422With an argument list, types the next matching message.
423.TP
424.B preserve
dcee403d 425(\fBpre\fR)
91d7df00 426A synonym for
dcee403d 427.BR hold .
91d7df00
KM
428.TP
429.B print
dcee403d
KM
430(\fBp\fR)
431Takes a message list and types out each message on the user's terminal.
91d7df00
KM
432.TP
433.B quit
434(\fBq\fR) Terminates the session, saving all undeleted, unsaved messages in
435the user's
436.I mbox
437file in his login directory, preserving all messages marked with
438.B hold
439or
440.B preserve
441or never referenced
442in his system mailbox, and removing all other messages from his system
443mailbox. If new mail has arrived during the session, the message
444``You have new mail'' is given. If given while editing a
445mailbox file with the
446.B \-f
447flag, then the edit file is rewritten. A return to the Shell is
448effected, unless the rewrite of edit file fails, in which case the user
449can escape with the
450.B exit
451command.
452.TP
453.B reply
dcee403d
KM
454(\fBr\fR)
455Takes a message list and sends mail to the sender and all
456recipients of the specified message.
457The default message must not be deleted.
91d7df00
KM
458.TP
459.B respond
460A synonym for
dcee403d 461.BR reply .
91d7df00 462.TP
bb04cec6
KM
463.B retain
464Add the list of header fields named to the
465.IR "retained list" .
466Only the header fields in the retain list
467are shown on your terminal when you print a message.
468All other header fields are suppressed.
469The
470.B Type
471and
472.B Print
473commands can be used to print a message in its entirety.
474If
475.B retain
476is executed with no arguments, it lists the current set of
477retained fields.
478.TP
91d7df00
KM
479.B save
480(\fBs\fR) Takes a message list and a filename and appends each message in
481turn to the end of the file. The filename in quotes, followed by the line
482count and character count is echoed on the user's terminal.
483.TP
484.B set
485(\fBse\fR) With no arguments, prints all variable values. Otherwise, sets
486option. Arguments are of the form
487``option=value''
bb04cec6 488(no space before or after =) or
91d7df00
KM
489``option.''
490.TP
491.B shell
492(\fBsh\fR) Invokes an interactive version of the shell.
493.TP
494.B size
495Takes a message list and prints out the size in characters of each
496message.
497.TP
dcee403d
KM
498.B source
499(\fBso\fR)
500The
501.B source
502command reads
503.I mail
504commands from a file.
505.TP
91d7df00
KM
506.B top
507Takes a message list and prints the top few lines of each. The number of
508lines printed is controlled by the variable
509.B toplines
510and defaults to five.
511.TP
512.B type
513(\fBt\fR) A synonym for
dcee403d 514.BR print .
91d7df00
KM
515.TP
516.B unalias
517Takes a list of names defined by
518.B alias
519commands and discards the remembered groups of users. The group names
520no longer have any significance.
521.TP
522.B undelete
634278dc 523(\fBu\fR) Takes a message list and marks each message as
91d7df00
KM
524.I not
525being deleted.
526.TP
634278dc
S
527.B unread
528(\fBU\fR) Takes a message list and marks each message as
529.I not
530having been read.
531.TP
91d7df00
KM
532.B unset
533Takes a list of option names and discards their remembered values;
534the inverse of
dcee403d 535.BR set .
91d7df00
KM
536.TP
537.B visual
538(\fBv\fR) Takes a message list and invokes the display editor on each message.
539.TP
540.B write
b3f2d791
S
541(\fBw\fR) Similar to
542.BR save ,
543except that
544.I only
545the message body (\fIwithout\fP the header) is saved.
546Extremely useful for such tasks as sending and receiving source
547program text over the message system.
91d7df00
KM
548.TP
549.B xit
550(\fBx\fR) A synonym for
dcee403d
KM
551.BR exit .
552.TP
553.B z
554.I Mail
555presents message headers in windowfuls as described under the
556.B headers
557command. You can move
558.IR mail 's
559attention forward to the next window with the
560.B z
561command. Also, you can move to the previous window by using
562.BR z\- .
91d7df00
KM
563.PP
564Here is a summary of the tilde escapes,
565which are used when composing messages to perform
566special functions. Tilde escapes are only recognized at the beginning
567of lines. The name
568``tilde\ escape''
569is somewhat of a misnomer since the actual escape character can be set
570by the option
571.B escape.
572.TP 12n
dcee403d 573.BR ~! command
91d7df00
KM
574Execute the indicated shell command, then return to the message.
575.TP
cb530a2d
KM
576\fB~b\fR name ...
577Add the given names to the list of carbon copy recipients but do not make
578the names visible in the Cc: line ("blind" carbon copy).
579.TP
91d7df00
KM
580\fB~c\fR name ...
581Add the given names to the list of carbon copy recipients.
582.TP
583.B ~d
584Read the file ``dead.letter'' from your home directory into the message.
585.TP
586.B ~e
587Invoke the text editor on the message collected so far. After the
588editing session is finished, you may continue appending text to the
589message.
590.TP
dcee403d
KM
591\fB~f\fR messages
592Read the named messages into the message being sent.
593If no messages are specified, read in the current message.
594.TP
91d7df00
KM
595.B ~h
596Edit the message header fields by typing each one in turn and allowing
597the user to append text to the end or modify the field by using the
598current terminal erase and kill characters.
599.TP
600\fB~m\fR messages
601Read the named messages into the message being sent, shifted right one
602tab. If no messages are specified, read the current message.
603.TP
604.B ~p
605Print out the message collected so far, prefaced by the message header
606fields.
607.TP
608.B ~q
609Abort the message being sent, copying the message to
610``dead.letter''
611in your home directory if
612.B save
613is set.
614.TP
615\fB~r\fR filename
616Read the named file into the message.
617.TP
618\fB~s\fR string
619Cause the named string to become the current subject field.
620.TP
621\fB~t\fR name ...
622Add the given names to the direct recipient list.
623.TP
624.B ~v
625Invoke an alternate editor (defined by the VISUAL option) on the
626message collected so far. Usually, the alternate editor will be a
627screen editor. After you quit the editor, you may resume appending
628text to the end of your message.
629.TP
630\fB~w\fR filename
631Write the message onto the named file.
632.TP
633\fB~\||\|\fRcommand
634Pipe the message through the command as a filter. If the command gives
635no output or terminates abnormally, retain the original text of the
636message. The command
637.IR fmt (1)
638is often used as
639.I command
640to rejustify the message.
641.TP
dcee403d 642.BR ~~ string
91d7df00
KM
643Insert the string of text in the message prefaced by a single ~. If
644you have changed the escape character, then you should double
645that character in order to send it.
646.PP
647Options are controlled via the
648.B set
649and
650.B unset
651commands. Options may be either binary, in which case it is only
652significant to see whether they are set or not, or string, in which
653case the actual value is of interest.
654The binary options include the following:
655.TP 15n
656.B append
657Causes messages saved in
658.I mbox
659to be appended to the end rather than prepended.
660(This is set in
661/usr/lib/Mail.rc
662on version 7 systems.)
663.TP
664.B ask
665Causes
666.I mail
667to prompt you for the subject of each message you send. If
668you respond with simply a newline, no subject field will be sent.
669.TP
670.B askcc
671Causes you to be prompted for additional carbon copy recipients at the
672end of each message. Responding with a newline indicates your
673satisfaction with the current list.
674.TP
675.B autoprint
676Causes the
677.B delete
678command to behave like
679.B dp
680\- thus, after deleting a message, the next one will be typed
681automatically.
682.TP
dcee403d
KM
683.B debug
684Setting the binary option
685.I debug
686is the same as specifying
687.B \-d
688on the command line and causes
689.I mail
690to output all sorts of information useful for debugging
691.IR mail .
692.TP
693.B dot
694The binary option
695.I dot
696causes
697.I mail
698to interpret a period alone on a line as the terminator
699of a message you are sending.
700.TP
701.B hold
702This option is used to hold messages in the system mailbox
703by default.
704.TP
91d7df00
KM
705.B ignore
706Causes interrupt signals from your terminal to be ignored and echoed as
707@'s.
708.TP
dcee403d
KM
709.B ignoreeof
710An option related to
711.I dot
712is
713.I ignoreeof
714which makes
715.I mail
716refuse to accept a control-d as the end of a message.
717.I Ignoreeof
718also applies to
719.I mail
720command mode.
721.TP
91d7df00
KM
722.B metoo
723Usually, when a group is expanded that contains the sender, the sender
724is removed from the expansion. Setting this option causes the sender
725to be included in the group.
726.TP
dcee403d
KM
727.B nosave
728Normally, when you abort a message with two \s-2RUBOUT\s0,
729.I mail
730copies the partial letter to the file ``dead.letter''
731in your home directory. Setting the binary option
732.I nosave
733prevents this.
734.TP
634278dc
S
735.B Replyall
736Reverses the sense of
737.I reply
738and
739.I Reply
740commands.
741.TP
91d7df00
KM
742.B quiet
743Suppresses the printing of the version when first invoked.
744.TP
dcee403d
KM
745.B verbose
746Setting the option
747.I verbose
748is the same as using the
749.B \-v
750flag on the command line. When mail runs in verbose mode,
751the actual delivery of messages is displayed on he users
752terminal.
91d7df00
KM
753.PP
754The following options have string values:
755.TP 15n
756EDITOR
757Pathname of the text editor to use in the
758.B edit
759command and ~e escape. If not defined, then a default editor is used.
760.TP
634278dc
S
761PAGER
762Pathname of the program to use in the
763.B more
764command or when
765.I crt
766variable is set. A default paginator is used if this option is
767not defined.
768.TP
91d7df00
KM
769SHELL
770Pathname of the shell to use in the
771.B !
772command and the ~! escape. A default shell is used if this option is
773not defined.
774.TP
775VISUAL
776Pathname of the text editor to use in the
777.B visual
778command and ~v escape.
779.TP
dcee403d
KM
780.B crt
781The valued option
782.I crt
783is used as a threshold to determine how long a message must
784be before
634278dc 785.B PAGER
dcee403d
KM
786is used to read it.
787.TP
91d7df00
KM
788.B escape
789If defined, the first character of this option gives the character to
790use in the place of ~ to denote escapes.
791.TP
dcee403d
KM
792.B folder
793The name of the directory to use for storing folders of
794messages. If this name begins with a `/',
795.I mail
796considers it to be an absolute pathname; otherwise, the
797folder directory is found relative to your home directory.
798.TP
91d7df00
KM
799.B record
800If defined, gives the pathname of the file used to record all outgoing
801mail. If not defined, then outgoing mail is not so saved.
802.TP
803.B toplines
804If defined, gives the number of lines of a message to be printed out
805with the
806.B top
807command; normally, the first five lines are printed.
808.SH FILES
809.if n .ta 2.5i
810.if t .ta 1.8i
811/usr/spool/mail/* post office
812.br
813~/mbox your old mail
814.br
815~/.mailrc file giving initial mail commands
816.br
817/tmp/R# temporary for editor escape
818.br
819/usr/lib/Mail.help* help files
820.br
821/usr/lib/Mail.rc system initialization file
822.br
dcee403d 823Message* temporary for editing messages
91d7df00 824.SH "SEE ALSO"
dcee403d
KM
825binmail(1), fmt(1), newaliases(1), aliases(5),
826.br
827mailaddr(7), sendmail(8)
91d7df00
KM
828.br
829`The Mail Reference Manual'
dcee403d
KM
830.SH BUGS
831There are many flags that are not documented here. Most are
832not useful to the general user.
833.br
834Usually,
835.I mail
836is just a link to
837.IR Mail ,
838which can be confusing.
91d7df00
KM
839.SH AUTHOR
840Kurt Shoens