MAIL(C) XENIX System V MAIL(C)
Name
mail - Sends, reads or disposes of mail.
Syntax
mail [[-u user] [-f mailbox]] [-e] [-R] [-i] [ users ...]
mail [-s subject] [-i] [ user ...]
Description
mail is a mail processing system that supports composing of
messages, and sending and receiving of mail between multiple
users. When sending mail, a user is the name of a user or
of an alias assigned to a machine or to a group of users.
Options include:
-u user
Tells mail to read the system mailbox belonging to the
specified user.
-f mailbox
Tells mail to read the specified mailbox instead of the
default user's system mailbox.
-e Allows escapes from compose mode when input comes from
a file.
-R Makes the mail session ``read-only'' by preventing
alteration of the mailbox being read. Useful when
accessing system-wide mailboxes.
-i Tells mail to ignore interrupts sent from the terminal.
This is useful when reading or sending mail over
telephone lines where ``noise'' may produce unwanted
interrupts.
-s subject
Specifies subject as the text of the Subject: field
for the message being sent.
Sending mail
To send a message to one or more other people, invoke mail
with arguments which are the names of people to send to. You
are then expected to type in your message, followed by a
Ctrl-D at the beginning of a line.
Reading Mail
To read mail, invoke mail with no arguments. This will check
your mail out of the system-wide directory so that you can
read and dispose of the messages sent to you. A message
header is printed out for each message in your mailbox. The
current message is initially the last numbered message and
Page 1 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
can be printed using the print command (which can be
abbreviated p). You can move among the messages much as you
move between lines in ed, with the commands + and - moving
backwards and forwards, and simple numbers typing the
addressed message.
If new mail arrives during the mail session, you can read in
the new messages with the restart command.
Note that you can configure your environment so that you are
notified whenever new mail is sent to you. To do so, you
would have to set the MAIL environment variable if you are
using the Bourne shell or the mail shell variable if you are
using the C-shell. For more information, see ``The Shell''
chapter of the
User's Guide and csh(C) in the User's Reference.
Disposing of Mail
After examining a message, you can delete (d) the message or
reply (r) to it. Deletion causes the mail program to forget
about the message. This is not irreversible, the message
can be undeleted (u) by giving its number, or the mail
session can be aborted by giving the exit (x) command.
Deleted messages will, however, disappear.
Specifying Messages
Commands such as print and delete often can be given a list
of message numbers as arguments to apply to a number of
messages at once. Thus ``delete 1 2'' deletes messages 1
and 2, while ``delete 1-5'' deletes messages 1 through 5.
The special name ``*'' addresses all messages, and ``$''
addresses the last message; thus the command top which
prints the first few lines of a message could be used in
``top *'' to print the first few lines of all messages.
Replying to or Originating Mail
You can use the reply command to set up a response to a
message, sending it back to the person who sent it. Then
you can enter in the text of the reply, and press Ctrl-D to
send it. While you are composing a message, mail treats
lines beginning with a tilde (~) as special. For instance,
typing ``~m'' alone on a line, places a copy of the current
message into the response, right shifting it by one tabstop.
Other escapes set up subject fields, add and delete
recipients to the message, and allow you to escape to an
editor to revise the message or to a shell to run some
commands. (These options are given in the summary below.)
Ending a Mail Session
You can end a mail session with the quit (q) command.
Messages that have been examined go to your mbox file unless
they have been deleted, in which case they are discarded.
Page 2 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
Unexamined messages go back to the post office. The -f
option causes mail to read in the contents of your mbox (or
the specified file) for processing; when you quit, mail
writes undeleted messages back to this file. The -i option
causes mail to ignore interrupts.
Using Aliases and Distribution Lists
It is also possible to create a personal distribution list.
For instance, you can send mail to ``cohorts'' and have it
go to a group of people. Such lists can be defined by
placing a line like
alias cohorts bill bob barry bobo betty beth bobbi
in the file .mailrc in your home directory. The current
list of such aliases can be displayed by the alias (a)
command in mail. System-wide distribution lists can be
created by editing /usr/lib/mail/aliases, see aliases(M);
these are kept in a slightly different syntax. In mail you
send, personal aliases will be expanded in mail sent to
others so that they will be able to reply to the recipients.
System-wide aliases are not expanded when the mail is sent,
but any reply returned to the machine will have the system-
wide alias expanded.
mail has a number of options which can be set in the .mailrc
file to alter its behavior; thus ``set askcc'' enables the
``askcc'' feature. (These options are summarized below.)
Summary
Each mail command is entered on a line by itself, and may
take arguments following the command word. The command need
not be entered in its entirety; the first command which
matches the typed prefix is used. For the commands that
take message lists as arguments; if no message list is
given, then the next message forward that satisfies the
command's requirements is used. If there are no messages
forward of the current message, the search proceeds
backwards, and if there are no messages at all, mail types
``No applicable messages'' and aborts the command.
- Goes to the previous message and prints it out.
If given a numeric argument n, goes to the nth
previous message and prints it.
+ Goes to the next message and prints it out. If
given a numeric argument n, goes to the nth next
message and prints it.
RETURN Goes to the next message and prints it out.
? Prints a brief summary of commands.
Page 3 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
! Executes the shell command which follows.
= Prints out the current message number.
^ Prints out the first message.
$ Prints out the last message.
alias (a) With no arguments, prints out all
currently-defined aliases. With one argument,
prints out that alias. With more than one
argument, adds the users named in the second and
later arguments to the alias named in the first
argument.
Alias users Prints system-wide list of aliases for users.
At least one user must be specified.
cd (c) Changes the user's working directory to that
specified, if given. If no directory is given,
then changes to the user's login directory.
delete (d) Takes a list of messages as an argument and
marks them all as deleted. Deleted messages are
not retained in the system mailbox after a quit,
nor are they available to any command other than
the undelete command.
dp Deletes the current message and prints the next
message. If there is no next message, mail says
``no more messages.''
echo path Expands shell metacharacters.
edit (e) Takes a list of messages and points the text
editor at each one in turn. On return from the
editor, the message is read back in.
exit (x) Effects an immediate return to the shell
without modifying the user's system mailbox, his
mbox file, or his edit file in -f.
file (fi) Prints the name of the file mail is
reading. If it is a mailbox, the name of the
owner is returned.
forward (f) Forwards the current message to the named
users. Current message is indented within
forwarded message.
Forward (F) Forwards the current message to the named
users. Current message is not indented within
Page 4 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
forwarded message.
headers (h) Lists the current range of headers, which is
an 18 message group. If a ``+'' argument is
given, then the next 18 message group is
printed, and if a ``-'' argument is given, the
previous 18 message group is printed. Both
``+'' and ``-'' may take a number to view a
particular window. If a message-list is given,
it prints the specified headers.
hold (ho) Takes a message list and marks each message
therein to be saved in the user's system mailbox
instead of in mbox. Use only when the switch
autombox is set. Does not override the delete
command.
list Prints list of mail commands.
lpr (l) Prints out each message in a message-list on
the lineprinter.
mail (m) Takes as arguments login names and
distribution group names and sends mail to those
people.
mbox (mb) Marks messages in a message list so that
they are saved in the user mailbox after leaving
mail.
move mesg-list mesg-num
Places the messages specified in mesg-list after
the message specified in mesg-num. If mesg-num
is 0, mesg-list moves to the top of the mailbox.
next (n like + or RETURN) Goes to the next message in
sequence and prints it. With an argument list,
types the next matching message.
print (p) Prints out each message in a message-list on
the terminal display.
quit (q) Terminates the session, retaining all
undeleted, unsaved messages in the system
mailbox and removing all other messages.
Messages marked with a star (*) are saved;
messages marked with an ``M'' are saved in the
user mailbox. If new mail has arrived during
the session, the message ``You have new mail''
is given. If given while editing a mailbox file
with the -f flag, then the mailbox file is
rewritten. The user returns to the shell, unless
Page 5 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
the rewrite of the mailbox file fails, in which
case the user can escape with the exit command.
reply (r) Takes a message list and sends mail to each
message author. The default message must not be
deleted.
Reply (R) Takes a message list and sends mail to each
message author and each member of the message
just like the mail command. The default message
must not be deleted.
restart Reads in messages that arrived during the
current mail session.
save (s) Takes a message list and a filename and
appends each message in turn to the end of the
file. The filename, in quotation marks, followed
by the line count and character count is echoed
on the user's terminal.
set (se) With no arguments, prints all variable
values. Otherwise, sets option. Arguments are of
the form ``option=value'' or ``option''.
shell (sh) Invokes an interactive version of the
shell.
size (si) Takes a message list and prints out the
size in characters of each message.
source (so) Reads mail commands from the file given as
its only argument.
string string mesg-list
Searches for string in mesg-list. If no mesg-
list is specified, all undeleted messages are
searched. Case is ignored in search.
top (t) Takes a message list and prints the top few
lines of each. The number of lines printed is
controlled by the variable toplines and defaults
to six.
undelete (u) Takes a message list and marks each one as
not being deleted.
unset (uns) Takes a list of option names and discards
their remembered values; the inverse of set.
visual (v) Takes a message list and invokes vi on each
message.
Page 6 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
whois Looks up a list of target mail recipients and
prints the real names or descriptions of each
recipient. If the first character of the first
argument is alphabetic, the arguments are looked
up without change. Otherwise, the arguments are
assumed to be a message list, in the format
specified in the Mail User's Guide. For each
message in the list, the ``From'' person is
extracted from the header and added to the list
of users to be searched.
If a target mail recipient contains a machine
and user name, nothing is printed. If it is a
private alias, ``private alias'' is printed. If
it is a global alias, the name or description of
the recipient is printed (contents of the $n
field in the alias file). If all of the above
fail, the user is looked up in /etc/passwd; if
the user is a local user, ``local user'' is
printed. Finally, if none of the above tests
and searches succeed, ``unknown'' is printed.
write filename
(w) Saves the body of the message in the named
file.
Here is a summary of the compose escapes, which are used
when composing messages to perform special functions.
Compose escapes are only recognized at the beginning of
lines.
~~string Inserts the string of text in the message
prefaced by a single tilde (~). If you have
changed the escape character, then you should
double that character instead.
~? Prints out help for compose escapes.
~. Same as Ctrl-D on a new line.
~!cmd Executes the indicated shell command, then
returns to the message.
~|cmd Pipes the message through the command as a
filter. If the command gives no output or
terminates abnormally, retains the original text
of the message.
~_ mail-command
Executes a mail command, then returns to compose
mode.
Page 7 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
~: mail-command
Executes a mail command, then returns to compose
mode.
~alias Prints list of private aliases
~alias aliasname
Prints names included in private aliasname.
~Alias Performs aliasing by first examining private
aliases and then system-wide aliases using all
three global alias files (aliases.hash,
faliases, and maliases). Only the final result
is printed (non-local mail recipients will have
the complete delivery path printed). The user
list is taken from header fields.
~Alias users
Performs aliasing by first examining private
aliases and then system-wide aliases using all
three global alias files (aliases.hash,
faliases, and maliases). Only the final result
is printed (non-local mail recipients will have
the complete delivery path printed). At least
one user must be specified.
~b name ... Adds the given names to the list of blind carbon
copy recipients.
~c name ... Adds the given names to the list of carbon copy
recipients.
~cc name ...
Same as ~c above.
~d Reads the file dead.letter from your home
directory into the message.
~e Invokes the text editor on the message collected
so far. After the editing session is finished,
you may continue appending text to the message.
~h Edits the message header fields by typing each
one in turn and allowing the user to append text
to the end or modify the field with the current
terminal erase and kill characters.
~m mesg-list
Reads the named messages into the message
buffer, shifted right one tab. If no messages
are specified, reads the current message.
Page 8 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
~M mesg-list
Reads the named messages into the message
buffer, with no indentation. If no messages are
specified, reads the current message.
~p Prints out the messages collected so far,
prefaced by the message header fields.
~Print Prints the real names or descriptions (in
parentheses) after each recipient in a header
field.
~q Aborts the message being sent, copying the
message to dead.letter in your home directory if
save is set.
~r filename Reads the named file into the message buffer.
~Return name
Adds the given names to the Return-receipt-to
field.
~s string Causes the named string to become the current
subject field.
~t name ... Adds the given names to the direct recipient
list.
~v Invokes a visual editor (defined by the VISUAL
option) on the message buffer. After you quit
the editor, you may resume appending text to the
end of your message.
~w filename Writes the body of the message to the named
file.
Options are controlled with the set and unset commands. An
option may be either a switch, in which case it is either on
or off, or a string, in which case the actual value is of
interest. The switch options include the following:
askcc Causes you to be prompted for additional
carbon copy recipients at the end of each
message. Responding with a newline indicates
your satisfaction with the current list.
asksubject Causes mail to prompt you for the subject of
each message you send. If you respond with
simply a newline, no subject field is sent.
autombox Causes all examined messages to be saved in
the user mailbox unless deleted or saved.
Page 9 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
autoprint Causes the delete command to behave like dp -
thus, after deleting a message, the next one
will be entered automatically.
chron Causes messages to be displayed in
chronological order.
dot Permits use of dot (.) as the end of file
character when composing messages.
execmail Causes the underbar prompt to return before
mail is finished being sent. This frees the
user to continue while mail performs mailing
functions in background.
ignore Causes interrupt signals from your terminal
to be ignored and echoed as at-signs (@).
mchron Causes messages to be listed in numerical
order (most recently received first), but
displayed in chronological order.
metoo Usually, when a group is expanded that
contains the sender, the sender is removed
from the expansion. Setting this option
causes the sender to be included in the
group.
nosave Prevents aborted messages from being appended
to the file dead.letter in your home
directory on receipt of two interrupts (or a
~q).
quiet Suppresses the printing of the version header
when first invoked.
verify Causes each target mail recipient to be
verified in the manner described in the whois
command. This option permits errors made
while composing messages to be corrected or
ignored.
The following options have string values:
EDITOR Pathname of the text editor to use in the
edit command and ~e escape. If not defined,
then a default editor (/bin/ed) is used.
SHELL Pathname of the shell to use in the ! command
and the ~! escape. A default shell (/bin/sh)
is used if this option is not defined.
Page 10 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
VISUAL Pathname of the text editor (/bin/vi) to use
in the visual command and ~v escape.
escape If defined, the first character of this
option gives the character to use in the
place of the tilde (~) to denote escapes.
page=n Specifies the number of lines (n) to be
printed in a ``page'' of text when displaying
messages.
record If defined, gives the pathname of the file
used to record all outgoing mail. If not
defined, then outgoing mail is not saved.
toplines If defined, gives the number of lines of a
message to be printed out with the top
command; normally, the first six lines are
printed.
Files
/usr/spool/mail/* System mailboxes
$HOME/dead.letter File where undeliverable mail is
deposited
$HOME/mbox Your old mail
$HOME/.mailrc File giving initial mail commands
/usr/lib/mail/aliases System-wide aliases
/usr/lib/mail/aliases.hash
System-wide alias database
/usr/lib/mail/faliases Forwarding aliases for the local
machine
/usr/lib/mail/maliases Machine aliases
/usr/lib/mail/mailhelp.cmd
Help file
/usr/lib/mail/mailhelp.esc
Help file
/usr/lib/mail/mailhelp.set
Help file
/usr/lib/mail/mailrc System initialization file
(defaults)
Page 11 (printed 2/7/91)
MAIL(C) XENIX System V MAIL(C)
/usr/bin/mail The mail command
See Also
aliases(M), aliashash(ADM), netutil(ADM)
Chapter 3, ``Mail,'' in the XENIX User's Guide.
Credit
This utility was developed at the University of California
at Berkeley and is used with permission.
Page 12 (printed 2/7/91)