MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
-------------------------------------------------------------------------------
mail, Mail
PURPOSE
Sends and receives mail.
SYNTAX
+------+ +----------------+ +-----------+
| mail |---| +------------+ |---| |--->
| Mail | +-| -file name |-+ +- user-ID -+
+------+ | -i |
| -n |
| -N |
| -s subject |
| -u user |
| -v |
+------------+
+----------------------------------------+
>---| +--------------------+ |--->
+- @ system-name -| |-+
+--- .domain_name ---+
^ |
+----------------+
+--------------------------------------+
>---| +------------+ +-------------+ |--->
+- : -| |---| |-+
+- uucphost -+ +- ! user-ID -+
+------------------------------------------------------+
>---| +--------------------+ |---|
+- : --- user-ID @ system_name -| |-+
+--- .domain_name ---+
^ |
+----------------+
DESCRIPTION
The 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 or Mail on the command
line with arguments that are the network addresses of the people who are to
Processed November 8, 1990 MAIL, MAIL(1,C) 1
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
receive the message. When the mail command 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 the Ctrl-D (EOF) sequence at the
beginning of the next line to exit the editor and send the message.
Mail standards limit mail to 7-bit ASCII characters. The mail utilites usually
do not handle multibyte characters except in the names of files on the local
system. However, multibyte characters included in a mail message are sent
reliably if the sender and the receiver are using the same locale and are in
the same AIX cluster.
When you have messages in your mailbox, the system displays the default
message:
[YOU HAVE NEW MAIL]
To look at the contents of your mailbox, enter the mail command without
arguments on the command line. The program displays a listing of the messages
in your mailbox and allows you to look at them, reply to them, or dispose of
them.
Reading Incoming Mail
To receive and read incoming mail, use the mail command with no arguments:
mail
The mail command then checks your system mailbox ($HOME/.newmail) and displays
a one-line entry for each message in the system mailbox similar to:
"$HOME/.newmail": 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 is included in the message).
From the mail command prompt &, you can enter commands to look at, reply to,
save, discard, or 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 additional commands, refer to the table on the following page.
Many mailbox commands allow you to specify groups of messages upon which you
can apply the command. Commands that allow you to specify groups of messages
Processed November 8, 1990 MAIL, MAIL(1,C) 2
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
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
uppercase or lowercase. 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
In this example, the command applies to all messages whose Subject: field
contains the letters "meet" in uppercase or lowercase. 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 uppercase or lowercase. 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"
Processed November 8, 1990 MAIL, MAIL(1,C) 3
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
The special character * (asterisk) addresses all messages, ^ (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 comments in mail script files.
-n Goes to the previous message and displays it. If given
number argument n, goes to the nth previous message and
displays it.
? Displays a brief summary of commands.
!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) The alternates command is useful if you have accounts
alt_list on several machines. Use it to inform the mail program that
the addresses listed in alt_list all refer to you. Then,
when you reply to messages, 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 displays
the current set of alternate names.
chdir dir (cd) Changes your working directory to the directory dir.
If no directory is given, it changes to your login
directory.
copy msg_lst (c, co) Appends each message in msg_lst in turn to the end
file of file. Displays the file name in quotes, followed by the
line count and character count, on the user's terminal.
Does not mark the messages it is used on to be deleted when
you quit.
delete msg_lst (d) Marks the messages in msg_lst to be deleted when you
quit the mail program. Deleted messages are neither saved
in your personal mailbox (see the mbox command) nor are they
available for most other commands. However, you can restore
messages that you have deleted while in the same mailbox
session (see the undelete mail command).
discard (di) Identical to the ignore command.
[fld_lst]
Processed November 8, 1990 MAIL, MAIL(1,C) 4
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
Command Function
dp Deletes the current message and displays the next message.
If there is no next message, the mail program displays one
of the following messages:
"at EOF" (There are active messages, but no more at
the end.)
"no more messages"
(No active messages.)
dt Deletes the current message and displays the next message.
If there is no message, the mail program displays one of the
following:
"at EOF" (There are active messages, but no more at
the end.)
"no more messages"
(No active messages.)
echo string Displays the character string string on the command line.
edit msg (e) Activates the editor that you define with the set
EDITOR= statement and loads message msg into the editor.
When you exit the editor, the saved message is replaced in
the mailbox being processed.
exit (ex or x) Exits to the shell without changing the mailbox
being processed. The mailbox returns to the condition that
it was in when the mail program was started. Messages
marked to be deleted are not deleted.
file [name] (fi) Identical to the folder command.
folder [name] (fo) Switches to a new mail file or folder. With no
arguments, displays 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. The following special conventions are recognized
for name:
# refers to the previous file
% refers to the system mailbox
& refers to your personal mailbox ($HOME/mbox)
+name refers to a file in your folder directory.
Processed November 8, 1990 MAIL, MAIL(1,C) 5
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
Command Function
folders Lists the names of the folders in your folder directory.
from msg_lst (f) Displays the headings of messages 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 messages 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 override the
delete command.
if condition Construction for conditional execution of mail commands.
else endif Commands following if are executed if condition is true.
Commands following else are executed if condition 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).
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 arguments, it
lists the current set of ignored fields.
list (l) Displays a list of valid 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 operation is the
default action for messages 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.
Processed November 8, 1990 MAIL, MAIL(1,C) 6
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
Command Function
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.
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 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, the
edit file is saved with changes. If the edit file cannot be
saved, 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 displayed 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 arguments, it lists the current set of
retained fields.
Processed November 8, 1990 MAIL, MAIL(1,C) 7
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
Command Function
save msg_lst (s) Appends the messages specified in msg_lst to file.
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 neither returned to the system mailbox nor
saved in your personal mailbox when you quit the 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 commands from file.
top msg_lst Displays the top few lines of the messages specified by
msg_lst. The number of lines displayed is determined 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 program, even though you have not
read the listed messages. The messages appear in your
personal mailbox as unread messages. When you use touch,
the last message in msg_lst becomes the current message.
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 specified 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.
unread msg_lst (U) Marks each message in msg_lst as not having been read.
Unread msg_lst Identical to the unread command.
Processed November 8, 1990 MAIL, MAIL(1,C) 8
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
Command Function
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 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 mailbox being processed.
write msg_lst (w) Appends the messages specified in msg_lst to file.
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 +
(plus) or no argument is given, the headings in the next
group are shown. If a - (minus) argument is given, the
headings in the previous group are shown.
Forwarding Mail
You can have mail forwarding by including a .forward file in your home
directory.
The .forward file contains a single line containing one of the following:
o Mail address for user.
o A list of user names, separated by commas.
o An absolute pathname where incoming messages are appended.
o A | (vertical bar) followed by an absolute pathname. Forwarded messages
are executed by the program specified by the pathname.
Handling Outgoing Mail
To compose and send a message, use mail with the following format:
mail addr_lst
In this format addr_lst is a list of user addresses separated by spaces. This
command activates the mail editor so that you can compose a message to be sent
to the specified addresses.
Processed November 8, 1990 MAIL, MAIL(1,C) 9
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
By default, 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= statement. To view a summary of many useful
commands, enter ~? on a line by itself while in the mail editor.
The following table 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 specified 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 program.
~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.
Processed November 8, 1990 MAIL, MAIL(1,C) 10
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
Command Function
~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 file name 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 specified 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 program.
~w file name 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
original 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.
~~ Allows you to use the character ~ (tilde) in a message
without its 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.
You can end a 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 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.
Processed November 8, 1990 MAIL, MAIL(1,C) 11
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
The format for using the set command to enable options not requiring a value
is:
set [option_list]
The option_list can be one or more options that you want to enable. To set
options so that they are valid each time you use 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
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 to prompt you for the subject of each message
you send. If you respond with a new line (carriage return),
no subject field is set.
askcc Causes you to be prompted for the addresses of people to
receive copies of the message. Responding with a new line
indicates your satisfaction with the current list.
autoprint Causes the delete command to behave like the dp command.
Thus, after deleting a message, the next one is typed
automatically.
debug Same as specifying -d on the command line. Causes mail to
display debugging information. The mail command does not
send mail while in debug mode.
dot Causes 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 the dot option. Makes mail refuse to accept an
Ctrl-D as the end of a message. ignoreeof also applies to
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).
Processed November 8, 1990 MAIL, MAIL(1,C) 12
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
Option Function
nosave Normally, when a message is terminated with two interrupt
sequences (Ctrl-C), 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
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.
The format for using the set command for options requiring a value is:
set option=value
Note: Do not use a space before or after the equal sign.
The following table 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, a default editor (/bin/ex) 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 path name is /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.
Processed November 8, 1990 MAIL, MAIL(1,C) 13
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
Option Function
folder Defines the name of the directory to use for storing folders
of messages. If this name begins with a / (slash), 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 used to record
all outgoing mail. If this name begins with a / (slash),
Mail considers it an absolute path name; otherwise it is
relative to $HOME. If not defined, 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.
FLAGS
-v Puts 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
on noisy phone lines.
-n Inhibits the reading of /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 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.
-u user_id Short way of doing mail -f/~userid/.newmail. Activates mail for a
specified users mailbox. You must have access permission to the
specified mailbox.
FILES
$HOME/mbox Your personal mailbox.
$HOME/.forward Forwards your mail as specified.
$HOME/.mailrc File containing mail commands to customize mail to a
specific user.
Processed November 8, 1990 MAIL, MAIL(1,C) 14
MAIL, MAIL(1,C) AIX Commands Reference MAIL, MAIL(1,C)
$HOME/.newmail Your system mailbox.
/tmp/R# Temporary for editor escape.
/usr/lib/Mail.help Help file for mailbox commands.
/usr/lib/Mail.tildehelp
Help file for mail editor commands.
/usr/lib/Mail.rc File containing mail commands to change mail for all
users on the system.
RELATED INFORMATION
See the following commands: "bellmail," "sendmail, mailq, newaliases," and
"uucp."
See the chapter about sending and receiving mail in Using the AIX Operating
System.
See also the chapters about Mail Handler (an alternative to mail) and about
managing the mail system in Managing the AIX Operating System.
Processed November 8, 1990 MAIL, MAIL(1,C) 15