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