mail, Mail
PURPOSE
Sends and receives mail.
SYNOPSIS
rmail user...
Sending Mail:
Handling Mail:
DESCRIPTION
The mail, Mail program allows you to:
o Compose a message and send it
o Receive a message and look at it
o Store received messages in your mailbox, or in
folders
o Discard messages.
To send a message to one or more persons, enter mail,
Mail on the command line with arguments that are the
network addresses of the people to receive the message.
When mail, Mail starts, you can type the message using an
editor similar to ed. When you are finished with the
message, press the Enter key at the end of a line, and
use a Ctrl-D (EOF) sequence at the beginning of the next
line to exit the editor and send the message.
When you have messages in your mailbox, the system dis-
plays a message to tell you. The default message is:
[YOU HAVE NEW MAIL]
To look at the contents of your mailbox, enter the mail,
Mail command without arguments on the command line. The
program displays a listing of the messages in your mail
box and allows you to look at them, reply to them or
dispose of them.
Reading Incoming Mail
To receive and read incoming mail, use mail, Mail with no
arguments:
mail
The mail, Mail command then checks your system mailbox
(/usr/mail/user_id) and displays a one-line entry for
each message in the system mailbox similar to:
"/usr/mail/geo": 2 messages 2 new
>N 1 amy Thu Sep 17 14:36 13/359 "Dept Meeting"
N 2 amy Thu Sep 17 16:28 13/416 "Dept Meeting Delayed"
&
The ">" symbol indicates the current message, or the
message that commands act on if you do not specify a
message number or list of message numbers. The other
fields, in order, in the listing represent:
1. Message number
2. User address of the sender
3. Date the message was sent
4. Size of the message in lines/characters
5. The subject of the message (if one was included in
the message).
From the mail command prompt &, you can enter commands to
look at, reply to, save, discard, or otherwise manage the
contents of the mailbox. To display a summary of some of
the commands that you can use to handle mail in your
mailbox, enter ? at the mail command prompt. For more
information on those commands and information on addi-
tional commands, refer to Figure 3.
Many mailbox commands allow you to specify groups of mes-
sages upon which to perform the command. Commands that
allow groups of messages use the parameter msg_lst in the
command format. For example, the format of the f command
(display information about messages) appears as:
& f msg_lst
In this format msg_lst can be one of the following:
o One or more message numbers separated by spaces
& f 1 2 4 7
o A range of message numbers indicated by the first and
last numbers in the range separated by a dash
& f 2-5
is the same as,
& f 2 3 4 5
o One or more addresses separated by spaces to apply
the command to messages received from those
addresses,
& f amy geo@zeus
The characters entered for an address need not match
the address exactly. They must only be contained in
the address field of the messages in either upper or
lower case. Therefore, the request for address "amy"
matches all of the following addresses (and many
others):
- "amy"
- "AmY"
- "amy@zeus"
- "hamy"
o A string, preceded by a slash, to match against the
Subject: field of the messages,
& f /meet
applies the command to all messages whose Subject:
field contains the letters "meet" in upper or lower
case. The characters entered for a match pattern do
not need to match the Subject: field exactly. They
must only be contained in the Subject: field of the
messages in either upper or lower case. Therefore,
the request for subject "meet" matches all of the
following subjects (and many others):
- "Meeting on Thursday"
- "Come to meeting tomorrow"
- "MEET ME IN ST. LOUIS"
The special character * (asterisk) addresses all mes-
sages, ^ (caret) addresses the first message, and $
(dollar sign) addresses the last message.
The following table lists the mail commands and describes
their functions.
Command Function
= Echoes the number of the current
message.
# Comment character for writing com-
ments in mail script files.
-n Goes to the previous message and
displays it. If given a number
argument of n, goes to the nth pre-
vious message and displays it.
? Displays a brief summary of com-
mands.
!sh_cmd Executes the AIX shell command
specified by sh_cmd.
alias (a) With no arguments, displays all
currently defined aliases. With one
argument, displays alias. With
more than one argument, creates a
new or changes an old alias.
alternates alt_list (alt) The alternates command is
useful if you have accounts on
several machines. Use it to inform
mail, Mail that the addresses
listed in alt_list all refer to
you. Then, when you reply to mes-
sages, mail, Mail does not send a
copy of the message to any of the
addresses given in alt_list. If
you enter the alternates command
with no argument, mail, Mail dis-
plays the current set of alternate
names.
chdir dir (cd) Changes your working direc-
tory to the directory dir. If no
directory is given, it changes to
your login directory.
copy msg_lst file (c, co) Appends each message in
msg_lst in turn to the end of file.
Displays the filename in quotes,
followed by the line count and
character count, on the user's ter-
minal. Does not mark the messages
it is used on to be deleted when
you quit.
Figure 3 (Part 1 of 7). Mailbox Commands
Command Function
delete msg_lst (d) Marks the messages in msg_lst
to be deleted when you quit mail,
Mail. Deleted messages are not
saved in mbox, nor are they avail-
able for most other commands.
However, you can restore messages
that you have deleted while in the
same mailbox session (see the unde-
lete mailbox command).
discard [fld_lst] (di) Identical to the ignore
command.
dp Deletes the current message and
displays the next message. If
there is no next message, mail,
Mail displays the message, "at
EOF".
dt Identical to the dp command.
echo string Displays the character string
string on the command line.
edit msg (e) Activates the editor that you
define with the set EDITOR= state-
ment and loads message msg into the
editor. When you exit the editor,
the saved message is replaced in
the mail box being processed.
exit (ex or x) Exits to the shell
without changing the mail box being
processed. The mail box returns to
the condition that it was when
mail, Mail was started. Messages
marked to be deleted are not
deleted.
file [name] (fi) Identical to the folder
command.
Figure 3 (Part 2 of 7). Mailbox Commands
Command Function
folder [name] (fo) Switches to a new mail file or
folder. With no arguments, dis-
plays the name of the mailbox that
you are currently reading. If an
argument is included, it stores the
current mailbox with changes (such
as messages deleted) and reads in
the new mailbox specified by the
name parameter. Some special con-
ventions are recognized for the
name:
o # refers to the previous file
o % refers to the system mailbox
o & refers to your personal
mailbox ($HOME/mbox)
o name refers to a file in your
folder directory.
folders Lists the names of the folders in
your folder directory.
from msg_lst (f) Displays the headings of mes-
sages in msg_lst.
group (g) Identical to the alias command.
headers (h) Lists the headings in the
current group of messages (each
group of messages contains 20 mes-
sages by default; change this with
the set screen= statement).
help Identical to question mark (?).
hold msg_lst (ho) Marks each message in msg_lst
to be saved in your system mailbox
instead of in mbox. Does not over-
ride the delete command.
if condition Construction for conditional exe-
else cution of mail, Mail commands.
endif Commands following if are executed
if condition is true. Commands
following else are executed if con-
dition is not true. The else is
not required. The endif ends the
construction and is required. The
condition can be "receive"
(receiving mail) or "send" (sending
mail).
Figure 3 (Part 3 of 7). Mailbox Commands
Command Function
ignore [fld_lst] Adds the header fields in fld_lst
to the list of fields to be
ignored. Ignored fields are not
displayed when you look at a
message with the t or p commands.
Use this command to suppress
machine-generated header fields.
Use the Type and Print commands to
print a message in its entirety,
including ignored fields. If
ignore is executed with no argu-
ments, it lists the current set of
ignored fields.
list (l) Displays a list of valid mail,
Mail commands.
local Lists other names for the local
host.
mail addr_lst (m) Activates the mail editor to
allow you to create and send a
message to people specified in
addr_lst.
mbox msg_lst Indicates that the messages in
msg_lst be sent to your personal
mailbox when you quit. This opera-
tion is the default action for mes-
sages that you have looked at if
you are looking at your system
mailbox and the hold option is not
set.
more msg_lst (mo) Displays the messages in
msg_lst using the defined pager
program to control display to the
screen.
More msg_lst (Mo) Like more but also displays
ignored header fields. See more
and ignore.
new msg_lst Identical to the unread command.
New msg_lst Identical to the Unread command.
next [msg] (n) Makes the next message in the
mailbox the current message and
displays that message. With an
argument list, it displays the next
matching message.
Figure 3 (Part 4 of 7). Mailbox Commands
Command Function
page msg_lst (pa) Identical to the more command.
Page msg_lst (Pa) Identical to the More command.
preserve (pre) Identical to the hold
command.
print msg_lst (p) Displays the messages in
msg_lst.
Print msg_lst (P) Like print but also displays
ignored header fields. See print
and ignore.
quit (q) Ends the session and returns to
the shell. Before ending, mail,
Mail saves all messages that have
not been deleted or saved in your
personal mailbox ($HOME/mbox). It
keeps all messages marked with hold
or preserve and those messages that
have not been looked at, in the
system mailbox. It removes all
other messages from the system
mailbox. If given while editing a
mailbox file with the -f flag, then
the edit file is saved with
changes. If the edit file cannot
be saved, mail, Mail does not exit.
Use the exit command to exit
without saving the changes.
reply msg Allows you to create and send mail
to the people who sent and received
the message specified in msg.
Reply msg Allows you to create and send mail
only to the person who sent the
message specified in msg.
respond msg Identical to the reply command.
Respond msg Identical to the Reply command.
retain [fld_lst] Adds the header fields in fld_lst
to the list of fields to be
retained. Retained fields are dis-
played when you look at a message
with the t or p commands. Use this
command to define which header
fields you want displayed. Use the
Type and Print commands to print a
message in its entirety, including
fields that are not retained. If
retain is executed with no argu-
ments, it lists the current set of
retained fields.
Figure 3 (Part 5 of 7). Mailbox Commands
Command Function
save msg_lst file (s) Appends the messages specified
in msg_lst to file. Displays the
file name and the size of the file
when the operation is complete. If
you save a message to a file, that
message is not returned to the
system mailbox nor saved in your
personal mailbox when you quit the
mail, Mail program.
set [option] (se) With no arguments, prints all
variable values. Otherwise, sets
an option as specified in option.
The option field can be either the
name of a binary option (an option
that is either set or not set) or a
statement of the form:
option=value
That assigns a value to a valued
option. Binary and valued options
are described later in this command
description.
shell (sh) Invokes an interactive
version of the shell.
size msg_lst Displays the sizes in
lines/characters of the messages in
msg_lst.
source file (so) Reads mail, Mail commands
from file.
top msg_lst Displays the top few lines of the
messages specified by msg_lst. The
number of lines displayed is deter-
mined by the valued option toplines
and defaults to five.
touch msg_lst When operating with your system
mailbox, this command marks the
messages in msg_lst to be moved to
your personal mailbox when you quit
the mail, Mail program, even though
you have not read the listed mes-
sages. The messages appear in your
personal mailbox as unread mes-
sages. When you use touch, the
last message in msg_lst becomes the
current message.
Figure 3 (Part 6 of 7). Mailbox Commands
Command Function
type msg_lst (t) Identical to the print command.
Type msg_lst (T) Identical to the Print command.
unalias al_lst Removes the defined aliases speci-
fied in al_lst.
undelete msg_lst (u) Removes the messages in msg_lst
from the list of messages to be
deleted when you quit mail, Mail.
unread msg_lst (U) Marks each message in msg_lst
as not having been read.
Unread msg_lst Identical to the unread command.
unset option_lst Discards the values of the options
specified in option_lst. This
action is the inverse of the set
command.
version (ve) Displays the version banner
for the mail, Mail program.
visual msg (v) Activates the editor that you
define with the" set VISUAL="
statement and loads message msg
into the editor. When you exit the
editor, the saved message is
replaced in the mail box being
processed.
write msg_lst file (w) Appends the messages specified
in msg_lst to file. Displays the
file name and the size of the file
when the operation is complete.
Does not include message headers in
the file.
xit (x) Identical to the exit command.
z [+] [-] Changes the current message group
(group of 20 messages) and displays
the headings of the messages in
that group. If a + or no argument
is give, then headings in the next
group are shown. If a - argument
is given, the headings in the pre-
vious group are shown.
Figure 3 (Part 7 of 7). Mailbox Commands
Handling Outgoing Mail
To compose and send a message, use mail, Mail with the
following format:
mail addr_lst
In this format addr_lst is a list of user addresses sepa-
rated by spaces. This command activates the mail editor
so that you can compose a message to be sent to the spec-
ified addresses.
By default, mail, Mail treats lines beginning with the
character ~ (tilde) as special while you are composing a
message. For instance, typing ~m on a line by itself
places a copy of the current message into the response,
shifting it to the right by one tab stop.
Other escapes set up subject fields, add and delete
recipients of the message, and allow the user to escape
to an editor to revise the message, or to a shell to run
other commands. You can change the escape character to
something other than a tilde with the set escape= state-
ment. To view a summary of many useful commands, enter
~? on a line by itself while in the mail editor.
Figure 4 shows a summary of the mail editor commands.
Use these commands only while in the mail editor. The
editor recognizes commands only if you enter them at the
beginning of a new line.
Command Function
~!cmd Executes the shell command, cmd and returns
to the message.
~b addr_lst Adds names in addr_lst to the list of
people to receive blind copies of the
message.
~c addr_lst Adds names in addr_lst to the list of
people to receive copies of the message.
~d Reads the file dead.letter from your home
directory into the message.
~e Activates the editor that you have speci-
fied with the" set EDITOR=" statement using
the message text in the current message.
When you exit that editor, you return to
the mail editor to continue appending the
changed message, or to send the message by
exiting the mail, Mail program.
Figure 4 (Part 1 of 3). Mail Editor Commands
Command Function
~f msg_lst Reads the named messages into the message
being sent. If no messages are specified,
reads the current message. This command
works only if you entered the mail editor
from the mailbox listing using the m or r
mailbox commands.
~h Allows you to edit the message header
fields by typing each one in turn. Allows
you to append text to the end or modify the
field using the current terminal erase and
kill characters.
~m msg_lst Reads the named messages into the message
being sent, shifted right one tab. If no
messages are specified, reads the current
message. This command works only if you
entered the mail editor from the mailbox
listing using the m or r mailbox commands.
~p Displays the message as it currently
exists, prefaced by the message header
fields.
~q Aborts the message being created without
sending it. Saves the message in
dead.letter in your home directory if the
save option is set.
~r filename Reads the named file into the message.
~s string Changes the "Subject:" field to the phrase
specified in string.
~t addr_lst Adds the addresses in addr_lst to the "To:"
field of the message.
~v Activates the editor that you have speci-
fied with the" set VISUAL=" statement using
the message text in the current message.
When you exit that editor, you return to
the mail editor to continue appending to
the changed message, or to send the message
by exiting the mail, Mail program.
~w filename Writes the message to the named file.
~|cmd Pipes the message through the command cmd
as a filter. If cmd gives no output or
terminates abnormally, it retains the ori-
ginal text of the message. Otherwise, the
output of cmd replaces the current message.
The command fmt is often used as command to
rejustify the message.
Figure 4 (Part 2 of 3). Mail Editor Commands
Command Function
~~ Allows you to use the character ~ (tilde)
in a message without it being interpreted
as a command prefix. The sequence ~~
results in only one ~ being sent in the
message. If you have changed the escape
character, double that character instead of
~ to use the new escape character as a
single character.
Figure 4 (Part 3 of 3). Mail Editor Commands
You can end a mail, Mail session with the quit (q)
command. Messages that you have looked at go to your
personal mailbox. Messages that you have marked to be
deleted are deleted. Messages that you have not looked
at go back to your system mailbox.
Customizing the Mail Program
The mail, Mail command has a number of options that you
can set to customize the mail system for your particular
use. Use the set command to enable options, and the
unset command to disable options. You can also use the
set command to assign a value to an option.
The format for using the set command to enable options
is:
set [option_list]
The option_list may be one or more options that you want
to enable. To set options so that they are valid each
time you use mail, Mail, put the commands in .mailrc in
your $HOME directory. To set options so that they are
valid for all users on the system, put the commands in
/usr/lib/Mail.rc. The following table, Figure 5, lists
the binary options (those that need only be set or
unset).
Option Function
append Causes messages saved in mbox to be appended
(added to the end) rather than prepended
(added to the beginning).
ask Causes mail, Mail to prompt you for the
subject of each message you send. If you
respond with a newline (carriage return), no
subject field is set.
Figure 5 (Part 1 of 2). Binary Options
Option Function
askcc Causes you to be prompted for the addresses
of people to receive copies of the message.
Responding with a newline indicates your
satisfaction with the current list.
autoprint Causes the delete command to behave like dp.
Thus, after deleting a message, the next one
is typed automatically.
debug Same as specifying -d on the command line.
Causes mail, Mail to display debugging
information. mail, Mail does not send mail
while in debug mode.
dot Causes mail, Mail to interpret a period
alone on a line as the terminator of a
message you are sending.
hold Holds messages in the system mailbox by
default.
ignore Causes interrupt signals from your terminal
to be ignored and echoed as @'s.
ignoreeof Related to dot. Makes mail, Mail refuse to
accept an Ctrl-D as the end of a message.
ignoreeof also applies to mail, Mail command
mode.
metoo Usually, when an alias containing the sender
is expanded, the sender is removed from the
expansion. Setting this option causes the
sender to be included in the alias expansion
(and thus receives copies of messages).
nosave Normally, when a message is terminated with
two interrupt sequences (Alt-Pause), mail,
Mail copies the partial letter to the file
dead.letter in your home directory. Setting
the binary option nosave prevents this.
Replyall Reverses the sense of the reply and Reply
mailbox commands.
quiet Suppresses the printing of the program
banner when mail, Mail starts.
verbose Same as using the -v flag on the command
line. When mail runs in verbose mode, the
actual delivery of messages is displayed on
the user's terminal.
Figure 5 (Part 2 of 2). Binary Options
The following table, Figure 6 lists the valued options
(those that need to be assigned a value).
Option Function
EDITOR Path name of the text editor to use in the
edit command and ~e escape. If not defined,
then a default editor (/usr/bin/e) is used.
PAGER Path name of the paging program to use for
the more command or when the crt variable is
set. If you do not specify a value for
PAGER, the system uses /bin/pg.
SHELL Path name of the shell to use in the !
command and the ~! escape. A default shell
is used if this option is not defined.
VISUAL Pathname of the text editor to use in the
visual command and ~v escape. The default
pathname is /usr/bin/vi.
crt=n Calls the pg command to display the message
when the message exceeds n lines.
escape If defined, the first character of this
option gives the character to use in the
place of ~ to denote escapes.
folder Defines the name of the directory to use for
storing folders of messages. If this name
begins with a /, mail, Mail considers it to
be an absolute path name; otherwise, the
folder directory is found relative to your
home directory.
record If defined, gives the path name of the file
(relative to $HOME) used to record all out-
going mail. If not defined, then outgoing
mail is not saved. Do not include the home
directory as part of the path name.
screen If defined, controls the size of the window
for message headers. You can set this option
to show the number of lines on the screen.
For example, the entry "screen=22" causes the
system to scroll for 22 lines and then pause.
toplines If defined, gives the number of lines of a
message to be printed out with the top
command; normally, the first five lines are
printed.
Figure 6. Valued Options
FLAGS
-v Puts mail, Mail into verbose mode. Details of
delivery are displayed on the user's terminal.
-i Causes tty interrupt signals to be ignored.
Useful when using mail, Mail on noisy phone
lines.
-n Inhibits the reading the /usr/lib/Mail.rc.
-N Suppresses the initial printing of headers.
-s subject Specifies a subject for a message to be
created.
-f name Causes mail, Mail to read in the contents of
your mbox or the specified file for proc-
essing. When you quit, mail, Mail writes
undeleted messages back to this file.
-u user_id Short way of doing mail, Mail -f
/usr/mail/user_id. Activates mail, Mail for a
specified users mailbox. You must have access
permission to the specified mailbox.
FILES
/usr/mail/* System mailboxes for all users.
$HOME/mbox Your personal mailbox.
$HOME/.mailrc File containing mail commands
to customize mail, Mail to a
specific user.
/tmp/R# Temporary for editor escape.
/usr/lib/Mail.help Help file for mailbox commands.
/usr/lib/Mail.tildehelp Help file for mail editor com-
mands.
/usr/lib/Mail.rc File containing mail commands
to change mail, Mail for all
users on the system.
RELATED INFORMATION
The following commands: "bellmail," "sendmail," and
"uucp."
The chapter about sending and receiving mail in IBM RT PC
Using the AIX Operating System.
See also, the chapters about Mail Handler (an alternative
to mail, Mail) and about managing the mail system in IBM
RT PC Managing the AIX Operating System.