1MAIL(1) BSD General Commands Manual MAIL(1)
2
4 mail — send and receive mail
5
7 mail [-iInv] [-s subject] [-c cc-addr] [-b bcc-addr] to-addr...
8 [-- sendmail-options...]
9 mail [-iInNv] -f [name]
10 mail [-iInNv] [-u user]
11
13 Mail is an intelligent mail processing system, which has a command syntax
14 reminiscent of ed(1) with lines replaced by messages.
15
16 -v Verbose mode. The details of delivery are displayed on the user's
17 terminal.
18
19 -i Ignore tty interrupt signals. This is particularly useful when
20 using mail on noisy phone lines.
21
22 -I Forces mail to run in interactive mode even when input isn't a ter‐
23 minal. In particular, the ‘~’ special character when sending mail
24 is only active in interactive mode.
25
26 -n Inhibits reading /etc/mail.rc upon startup.
27
28 -N Inhibits the initial display of message headers when reading mail
29 or editing a mail folder.
30
31 -s Specify subject on command line (only the first argument after the
32 -s flag is used as a subject; be careful to quote subjects contain‐
33 ing spaces.)
34
35 -c Send carbon copies to list of users.
36
37 -b Send blind carbon copies to list. List should be a comma-separated
38 list of names.
39
40 -f Read in the contents of your mbox (or the specified file) for pro‐
41 cessing; when you quit, mail writes undeleted messages back to this
42 file.
43
44 -u Is equivalent to:
45
46 mail -f /var/spool/mail/user
47
48 Sending mail
49 To send a message to one or more people, mail can be invoked with argu‐
50 ments which are the names of people to whom the mail will be sent. You
51 are then expected to type in your message, followed by an ‘control-D’ at
52 the beginning of a line. The section below Replying to or originating
53 mail, describes some features of mail available to help you compose your
54 letter.
55
56 Reading mail
57 In normal usage mail is given no arguments and checks your mail out of
58 the post office, then prints out a one line header of each message found.
59 The current message is initially the first message (numbered 1) and can
60 be printed using the print command (which can be abbreviated ‘p’). You
61 can move among the messages much as you move between lines in ed(1), with
62 the commands ‘+’ and ‘-’ moving backwards and forwards, and simple num‐
63 bers.
64
65 Disposing of mail.
66 After examining a message you can delete ‘d’) the message or reply ‘r’)
67 to it. Deletion causes the mail program to forget about the message.
68 This is not irreversible; the message can be undeleted ‘u’) by giving its
69 number, or the mail session can be aborted by giving the exit ‘x’) com‐
70 mand. Deleted messages will, however, usually disappear never to be seen
71 again.
72
73 Specifying messages
74 Commands such as print and delete can be given a list of message numbers
75 as arguments to apply to a number of messages at once. Thus “delete 1 2”
76 deletes messages 1 and 2, while “delete 1-5” deletes messages 1 through
77 5. The special name ‘*’ addresses all messages, and ‘$’ addresses the
78 last message; thus the command top which prints the first few lines of a
79 message could be used in “top *” to print the first few lines of all mes‐
80 sages.
81
82 Replying to or originating mail.
83 You can use the reply command to set up a response to a message, sending
84 it back to the person who it was from. Text you then type in, up to an
85 end-of-file, defines the contents of the message. While you are compos‐
86 ing a message, mail treats lines beginning with the character ‘~’ spe‐
87 cially. For instance, typing ‘~m’ (alone on a line) will place a copy of
88 the current message into the response right shifting it by a tabstop (see
89 indentprefix variable, below). Other escapes will set up subject fields,
90 add and delete recipients to the message and allow you to escape to an
91 editor to revise the message or to a shell to run some commands. (These
92 options are given in the summary below.)
93
94 Ending a mail processing session.
95 You can end a mail session with the quit ‘q’) command. Messages which
96 have been examined go to your mbox file unless they have been deleted in
97 which case they are discarded. Unexamined messages go back to the post
98 office. (See the -f option above).
99
100 Personal and systemwide distribution lists.
101 It is also possible to create a personal distribution lists so that, for
102 instance, you can send mail to “cohorts” and have it go to a group of
103 people. Such lists can be defined by placing a line like
104
105 alias cohorts bill ozalp jkf mark kridle@ucbcory
106
107 in the file .mailrc in your home directory. The current list of such
108 aliases can be displayed with the alias command in mail. System wide
109 distribution lists can be created by editing /etc/aliases, see aliases(5)
110 and sendmail(8); these are kept in a different syntax. In mail you send,
111 personal aliases will be expanded in mail sent to others so that they
112 will be able to reply to the recipients. System wide aliases are not
113 expanded when the mail is sent, but any reply returned to the machine
114 will have the system wide alias expanded as all mail goes through
115 sendmail.
116
117 Network mail (ARPA, UUCP, Berknet)
118 See mailaddr(7) for a description of network addresses.
119
120 Mail has a number of options which can be set in the .mailrc file to
121 alter its behavior; thus “set askcc” enables the askcc feature. (These
122 options are summarized below.)
123
125 (Adapted from the `Mail Reference Manual')
126
127 Each command is typed on a line by itself, and may take arguments follow‐
128 ing the command word. The command need not be typed in its entirety -
129 the first command which matches the typed prefix is used. For commands
130 which take message lists as arguments, if no message list is given, then
131 the next message forward which satisfies the command's requirements is
132 used. If there are no messages forward of the current message, the
133 search proceeds backwards, and if there are no good messages at all, mail
134 types “No applicable messages” and aborts the command.
135
136 - Print out the preceding message. If given a numeric argument n,
137 goes to the n'th previous message and prints it.
138
139 ? Prints a brief summary of commands.
140
141 ! Executes the shell (see sh(1) and csh(1)) command which follows.
142
143 Print (P) Like print but also prints out ignored header fields. See
144 also print, ignore and retain.
145
146 Reply (R) Reply to originator. Does not reply to other recipients of
147 the original message.
148
149 Type (T) Identical to the Print command.
150
151 alias (a) With no arguments, prints out all currently-defined aliases.
152 With one argument, prints out that alias. With more than one
153 argument, creates a new alias or changes an old one.
154
155 alternates
156 (alt) The alternates command is useful if you have accounts on
157 several machines. It can be used to inform mail that the listed
158 addresses are really you. When you reply to messages, mail will
159 not send a copy of the message to any of the addresses listed on
160 the alternates list. If the alternates command is given with no
161 argument, the current set of alternate names is displayed.
162
163 chdir (c) Changes the user's working directory to that specified, if
164 given. If no directory is given, then changes to the user's
165 login directory.
166
167 copy (co) The copy command does the same thing that save does, except
168 that it does not mark the messages it is used on for deletion
169 when you quit.
170
171 delete (d) Takes a list of messages as argument and marks them all as
172 deleted. Deleted messages will not be saved in mbox, nor will
173 they be available for most other commands.
174
175 dp (also dt) Deletes the current message and prints the next mes‐
176 sage. If there is no next message, mail says “at EOF”.
177
178 edit (e) Takes a list of messages and points the text editor at each
179 one in turn. On return from the editor, the message is read back
180 in.
181
182 exit (ex or x) Effects an immediate return to the Shell without modi‐
183 fying the user's system mailbox, his mbox file, or his edit file
184 in -f.
185
186 file (fi) The same as folder.
187
188 folders
189 List the names of the folders in your folder directory.
190
191 folder (fo) The folder command switches to a new mail file or folder.
192 With no arguments, it tells you which file you are currently
193 reading. If you give it an argument, it will write out changes
194 (such as deletions) you have made in the current file and read in
195 the new file. Some special conventions are recognized for the
196 name. # means the previous file, % means your system mailbox,
197 %user means user's system mailbox, & means your mbox file, and
198 +folder means a file in your folder directory.
199
200 from (f) Takes a list of messages and prints their message headers.
201
202 headers
203 (h) Lists the current range of headers, which is an 18-message
204 group. If a ‘+’ argument is given, then the next 18-message
205 group is printed, and if a ‘-’ argument is given, the previous
206 18-message group is printed.
207
208 help A synonym for ?
209
210 hold (ho, also preserve) Takes a message list and marks each message
211 therein to be saved in the user's system mailbox instead of in
212 mbox. Does not override the delete command.
213
214 ignore Add the list of header fields named to the ignored list. Header
215 fields in the ignore list are not printed on your terminal when
216 you print a message. This command is very handy for suppression
217 of certain machine-generated header fields. The Type and Print
218 commands can be used to print a message in its entirety, includ‐
219 ing ignored fields. If ignore is executed with no arguments, it
220 lists the current set of ignored fields.
221
222 mail (m) Takes as argument login names and distribution group names
223 and sends mail to those people.
224
225 mbox Indicate that a list of messages be sent to mbox in your home
226 directory when you quit. This is the default action for messages
227 if you do not have the hold option set.
228
229 next (n) like + or CR) Goes to the next message in sequence and types
230 it. With an argument list, types the next matching message.
231
232 preserve
233 (pre) A synonym for hold.
234
235 print (p) Takes a message list and types out each message on the user's
236 terminal.
237
238 quit (q) Terminates the session, saving all undeleted, unsaved mes‐
239 sages in the user's mbox file in his login directory, preserving
240 all messages marked with hold or preserve or never referenced in
241 his system mailbox, and removing all other messages from his sys‐
242 tem mailbox. If new mail has arrived during the session, the
243 message “You have new mail” is given. If given while editing a
244 mailbox file with the -f flag, then the edit file is rewritten.
245 A return to the Shell is effected, unless the rewrite of edit
246 file fails, in which case the user can escape with the exit com‐
247 mand.
248
249 reply (r) Takes a message list and sends mail to the sender and all
250 recipients of the specified message. The default message must
251 not be deleted.
252
253 respond
254 A synonym for reply.
255
256 retain Add the list of header fields named to the retained list Only the
257 header fields in the retain list are shown on your terminal when
258 you print a message. All other header fields are suppressed.
259 The Type and Print commands can be used to print a message in its
260 entirety. If retain is executed with no arguments, it lists the
261 current set of retained fields.
262
263 save (s) Takes a message list and a filename and appends each message
264 in turn to the end of the file. The filename in quotes, followed
265 by the line count and character count is echoed on the user's
266 terminal.
267
268 set (se) With no arguments, prints all variable values. Otherwise,
269 sets option. Arguments are of the form option=value (no space
270 before or after =) or option. Quotation marks may be placed
271 around any part of the assignment statement to quote blanks or
272 tabs, i.e. “set indentprefix="->"”
273
274 saveignore
275 Saveignore is to save what ignore is to print and type. Header
276 fields thus marked are filtered out when saving a message by save
277 or when automatically saving to mbox.
278
279 saveretain
280 Saveretain is to save what retain is to print and type. Header
281 fields thus marked are the only ones saved with a message when
282 saving by save or when automatically saving to mbox. Saveretain
283 overrides saveignore.
284
285 shell (sh) Invokes an interactive version of the shell.
286
287 size Takes a message list and prints out the size in characters of
288 each message.
289
290 source The source command reads commands from a file.
291
292 top Takes a message list and prints the top few lines of each. The
293 number of lines printed is controlled by the variable toplines
294 and defaults to five.
295
296 type (t) A synonym for print.
297
298 unalias
299 Takes a list of names defined by alias commands and discards the
300 remembered groups of users. The group names no longer have any
301 significance.
302
303 undelete
304 (u) Takes a message list and marks each message as not being
305 deleted.
306
307 unread (U) Takes a message list and marks each message as not having
308 been read.
309
310 unset Takes a list of option names and discards their remembered val‐
311 ues; the inverse of set.
312
313 visual (v) Takes a message list and invokes the display editor on each
314 message.
315
316 write (w) Similar to save, except that only the message body (without)
317 the header) is saved. Extremely useful for such tasks as sending
318 and receiving source program text over the message system.
319
320 xit (x) A synonym for exit.
321
322 z Mail presents message headers in windowfuls as described under
323 the headers command. You can move mail's attention forward to
324 the next window with the z command. Also, you can move to the
325 previous window by using z-.
326
327 Tilde/Escapes
328 Here is a summary of the tilde escapes, which are used when composing
329 messages to perform special functions. Tilde escapes are only recognized
330 at the beginning of lines. The name “tilde escape” is somewhat of a mis‐
331 nomer since the actual escape character can be set by the option escape.
332
333 ~!command
334 Execute the indicated shell command, then return to the message.
335
336 ~bname ...
337 Add the given names to the list of carbon copy recipients but do
338 not make the names visible in the Cc: line ("blind" carbon copy).
339
340 ~cname ...
341 Add the given names to the list of carbon copy recipients.
342
343 ~d Read the file “dead.letter” from your home directory into the
344 message.
345
346 ~e Invoke the text editor on the message collected so far. After
347 the editing session is finished, you may continue appending text
348 to the message.
349
350 ~fmessages
351 Read the named messages into the message being sent. If no mes‐
352 sages are specified, read in the current message. Message head‐
353 ers currently being ignored (by the ignore or retain command) are
354 not included.
355
356 ~Fmessages
357 Identical to ~f, except all message headers are included.
358
359 ~h Edit the message header fields by typing each one in turn and
360 allowing the user to append text to the end or modify the field
361 by using the current terminal erase and kill characters.
362
363 ~mmessages
364 Read the named messages into the message being sent, indented by
365 a tab or by the value of indentprefix. If no messages are speci‐
366 fied, read the current message. Message headers currently being
367 ignored (by the ignore or retain command) are not included.
368
369 ~Mmessages
370 Identical to ~m, except all message headers are included.
371
372 ~p Print out the message collected so far, prefaced by the message
373 header fields.
374
375 ~q Abort the message being sent, copying the message to
376 “dead.letter” in your home directory if save is set.
377
378 ~rfilename
379 Read the named file into the message.
380
381 ~sstring
382 Cause the named string to become the current subject field.
383
384 ~tname ...
385 Add the given names to the direct recipient list.
386
387 ~v Invoke an alternate editor (defined by the VISUAL option) on the
388 message collected so far. Usually, the alternate editor will be
389 a screen editor. After you quit the editor, you may resume
390 appending text to the end of your message.
391
392 ~wfilename
393 Write the message onto the named file.
394
395 ~|command
396 Pipe the message through the command as a filter. If the command
397 gives no output or terminates abnormally, retain the original
398 text of the message. The command fmt(1) is often used as command
399 to rejustify the message.
400
401 ~:mail-command
402 Execute the given mail command. Not all commands, however, are
403 allowed.
404
405 ~~string
406 Insert the string of text in the message prefaced by a single ~.
407 If you have changed the escape character, then you should double
408 that character in order to send it.
409
410 Mail Options
411 Options are controlled via set and unset commands. Options may be either
412 binary, in which case it is only significant to see whether they are set
413 or not; or string, in which case the actual value is of interest. The
414 binary options include the following:
415
416 append Causes messages saved in mbox to be appended to the end rather
417 than prepended. This should always be set (perhaps in
418 /etc/mail.rc).
419
420 ask, asksub
421 Causes mail to prompt you for the subject of each message you
422 send. If you respond with simply a newline, no subject field
423 will be sent.
424
425 askcc Causes you to be prompted for additional carbon copy recipients
426 at the end of each message. Responding with a newline indicates
427 your satisfaction with the current list.
428
429 askbcc Causes you to be prompted for additional blind carbon copy recip‐
430 ients at the end of each message. Responding with a newline
431 indicates your satisfaction with the current list.
432
433 autoprint
434 Causes the delete command to behave like dp - thus, after delet‐
435 ing a message, the next one will be typed automatically.
436
437 debug Setting the binary option debug is the same as specifying -d on
438 the command line and causes mail to output all sorts of informa‐
439 tion useful for debugging mail.
440
441 dot The binary option dot causes mail to interpret a period alone on
442 a line as the terminator of a message you are sending.
443
444 hold This option is used to hold messages in the system mailbox by
445 default.
446
447 ignore Causes interrupt signals from your terminal to be ignored and
448 echoed as @'s.
449
450 ignoreeof
451 An option related to dot is ignoreeof which makes mail refuse to
452 accept a control-d as the end of a message. Ignoreeof also
453 applies to mail command mode.
454
455 metoo Usually, when a group is expanded that contains the sender, the
456 sender is removed from the expansion. Setting this option causes
457 the sender to be included in the group.
458
459 noheader
460 Setting the option noheader is the same as giving the -N flag on
461 the command line.
462
463 nosave Normally, when you abort a message with two RUBOUT (erase or
464 delete) mail copies the partial letter to the file “dead.letter”
465 in your home directory. Setting the binary option nosave pre‐
466 vents this.
467
468 Replyall
469 Reverses the sense of reply and Reply commands.
470
471 quiet Suppresses the printing of the version when first invoked.
472
473 searchheaders
474 If this option is set, then a message-list specifier in the form
475 ``/x:y'' will expand to all messages containing the substring
476 ``y'' in the header field ``x''. The string search is case
477 insensitive.
478
479 verbose
480 Setting the option verbose is the same as using the -v flag on
481 the command line. When mail runs in verbose mode, the actual
482 delivery of messages is displayed on the user's terminal.
483
484 Option String Values
485 EDITOR Pathname of the text editor to use in the edit command and
486 ~e escape. If not defined, then a default editor is used.
487
488 LISTER Pathname of the directory lister to use in the folders com‐
489 mand. Default is /bin/ls.
490
491 PAGER Pathname of the program to use in the more command or when
492 crt variable is set. The default paginator more(1) is used
493 if this option is not defined.
494
495 SHELL Pathname of the shell to use in the ! command and the ~!
496 escape. A default shell is used if this option is not
497 defined.
498
499 VISUAL Pathname of the text editor to use in the visual command
500 and ~v escape.
501
502 crt The valued option crt is used as a threshold to determine
503 how long a message must be before PAGER is used to read it.
504 If crt is set without a value, then the height of the ter‐
505 minal screen stored in the system is used to compute the
506 threshold (see stty(1)).
507
508 escape If defined, the first character of this option gives the
509 character to use in the place of ~ to denote escapes.
510
511 folder The name of the directory to use for storing folders of
512 messages. If this name begins with a `/', mail considers
513 it to be an absolute pathname; otherwise, the folder direc‐
514 tory is found relative to your home directory.
515
516 MBOX The name of the mbox file. It can be the name of a folder.
517 The default is “mbox” in the user's home directory.
518
519 record If defined, gives the pathname of the file used to record
520 all outgoing mail. If not defined, then outgoing mail is
521 not so saved.
522
523 indentprefix String used by the ``~m'' tilde escape for indenting mes‐
524 sages, in place of the normal tab character (^I). Be sure
525 to quote the value if it contains spaces or tabs.
526
527 toplines If defined, gives the number of lines of a message to be
528 printed out with the top command; normally, the first five
529 lines are printed.
530
532 Mail utilizes the HOME, USER, SHELL, DEAD, PAGER, LISTER, EDITOR, VISUAL
533 and MBOX environment variables.
534
536 /var/spool/mail/* Post office.
537 ~/mbox User's old mail.
538 ~/.mailrc File giving initial mail commands. Only
539 used if the owner of the file is the user
540 running this copy of mail.
541 /tmp/R* Temporary files.
542 /usr/share/mailx/mail.*help Help files.
543 /etc/mail.rc System initialization file.
544
546 fmt(1), newaliases(1), vacation(1), aliases(5), mailaddr(7), sendmail(8)
547 and
548
549 The Mail Reference Manual..
550
552 A mail command appeared in Version 6 AT&T UNIX. This man page is derived
553 from The Mail Reference Manual originally written by Kurt Shoens.
554
556 There are some flags that are not documented here. Most are not useful
557 to the general user.
558
5594th Berkeley Distribution December 30, 1993 4th Berkeley Distribution