mail -e
mail -f [ -dHNn ] [ -F ] [ FileName ]
mail [ -dHNn ] [ -F ] [ -u UserID ]
mail [ -s Subject ] [ -c Address(es) ] [ -dinNv ] Address
The mail command invokes the mail utility, enabling you to:
In addition, you can use the available options and subcommands to customize the way you send and receive mail.
The mail command operates on two types of mailboxes, the system mailbox and the personal mailbox.
Incoming mail is stored in the system mailbox. By default, a user's system mailbox is a file located in the /var/spool/mail directory. The mailbox file is named after the userID. For example, if your userID is jeanne, then your system mailbox is /var/spool/mail/jeanne.
By default, when a user has read, deleted, or saved all the mail in their system mailbox, the mailbox is deleted. To prevent the mailbox from being deleted, use the set subcommand to set the keep option.
In addition to the system mailbox, there is the user's personal mailbox. As messages are read, if they are not deleted or saved to a file, they will be marked to be moved to the personal mailbox. The personal mailbox, by default, is $HOME/mbox. For example, if your home directory is /home/lance, then /home/lance/mbox is your personal mailbox. The messages remain in your personal mailbox until you move them to a folder or delete them.
Folders provide a way to save messages in an organized fashion. You can create as many folders as you need. Name each folder with a name that pertains to the subject matter of the messages it contains.
Note: Results can be unpredictable when running multiple instances of the mail command on one mailbox.
To process your mail, enter mail at the system prompt. The Mail program displays a one-line entry for each piece of mail in your system mailbox:
Mail [5.2 UCB] [AIX 4.1] Type ? for help. "/var/spool/mail/lance": 2 messages 2 new >N 1 karen Thu Sep 17 14:36 13/359 "Dept Meeting" N 2 lance@zeus Thu Sep 17 15:06 10/350 "Delay" N 3 karen Thu Sep 17 14:36 13/359 "Meeting Cancel"
The current message is marked by a > at the beginning of a line in the header summary.
Each one-line entry displays the
following fields:
Finally, following the list of mail, the Mail program displays the mailbox prompt, which by default is ?, to indicate that it is waiting for input.
The following environment
variables affect the execution of mail:
The Bourne shell (bsh
command) uses and checks the following variables. These variables can
be set in $HOME/.profile.
The mail command lists every messages in your system
mailbox. The mail system then displays the mailbox prompt (?) to
indicate waiting for input. When you see this prompt, enter
any mailbox subcommand. To see a list of subcommands, enter:
?
This entry lists the Mail subcommands.
mail -c "user2@host2 user3@host3" user1@host1<letter
mail -f
This command displays a list of the messages in your personal mailbox, $HOME/mbox.
mail -f +dept
This command displays a listing of the messages in the dept folder.
mail ron
When you finish entering the message to user ron, press the Enter key and press either . (period) or Ctrl-D to exit the editor and send the message. To determine if a user is on your local system, check for the user's name in your /etc/passwd file.
If your message is delivered successfully, you receive no notification. If your message could not be delivered, an error message is sent to you.
mail karen < letter1
This command sends the contents of the file letter1 to user karen on your local system. After the command sends the file, the Mail program displays the command line prompt.
mail dale@zeus
You now can create a message to dale. In this example, you are sending a message to user dale on remote system zeus. To send a message to a user on another system connected to your system through a network, you must know that person's login ID and the name of the other system.
From the mail prompt, ? (question mark), you can enter subcommands to manipulate mail in your mailbox. Subcommands that work on more than one message at a time use the MessageList parameter. Subcommands that work with files or folders use the FileName parameter. These parameters are discussed in "Summary of Mailbox Subcommands in the Mail Program" in AIX 5L Version 5.1 System User's Guide: Communications and Networks.
The following list describes the
Mailbox subcommands and their functions:
= | Echoes the number of the current message. |
# | Comment character for writing comments in mail script files. |
- | Displays the previous message. |
? | Displays a brief summary of mailbox subcommands. Identical to the help subcommand. |
!Command | Executes the workstation shell command specified by Command. |
alias | (a) With no arguments, displays all currently defined aliases and their corresponding addresses. With one argument, displays one alias. With more than one argument, creates a new alias or changes an old alias. Identical to the group subcommand. |
alternates AlternatesList | (alt) The alternates subcommand is useful if you have accounts on several machines. Use the subcommand to inform the Mail program that the addresses listed in AlternatesList all refer to you. When you use the reply subcommand to reply to messages, the Mail program does not send a copy of the message to any of the addresses given in AlternatesList. If you enter the alternates subcommand with no argument, the Mail program displays the current set of alternate names. |
chdir Directory | (cd) Changes your working directory to the indicated Directory. If no directory is given, it changes to your login directory. |
copy [MessageList] File | (c, co) Appends each message in MessageList to the end of File. Displays the file name in quotes, followed by the line count and character count, on the user's terminal. Does not delete any messages when you quit. |
Copy [MessageList] | (C) Saves the specified message in a file whose name is derived from the author of the message to be saved, without marking the messages as saved. Otherwise, it is equivalent to the Save subcommand. |
delete [MessageList] | (d) Marks the messages in MessageList to be deleted when you quit the Mail program. Entering the d subcommand without a message list deletes the current message. Deleted messages are not saved in your $HOME/mbox file nor are they available for most other commands. However, you can use the undelete subcommand to restore messages you have deleted while in the same mailbox session. If you delete a message and either change to another mailbox or quit the mailbox with the quit subcommand, the deleted message cannot be recalled. |
discard [FieldList] | (di) Identical to the ignore
subcommand.
Note: The retain subcommand overrides the discard subcommand. |
dp | Deletes the current message and displays the next message. If there is no next message, the Mail program displays EOF. Identical to the dt subcommand. |
dt | Deletes the current message and displays the next message. If there is no next message, the Mail program displays EOF. Identical to the dp subcommand. |
echo String | Displays the character string String on the command line. |
edit [MessageList] | (e) Starts the alternate editor using the MessageList as input files. To define an alternate editor, use the set EDITOR= statement or place an entry in your $HOME/.mailrc file. Any message specified by the MessageList parameter retains the changes made during the editor session. |
exit | (ex or x) Leaves the mailbox and returns to the operating system without changing the original contents of the mailbox. The mailbox returns to the condition that it was when the Mail program was started. Messages marked to be deleted are not deleted. Identical to the xit subcommand. |
file [Name] | (fi) Identical to the folder subcommand. |
folder [Name] | (fo) Switches to a new mail file or folder. With no arguments, the subcommand displays the name of the current mailbox. 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. Identical to the file subcommand. |
folders | Lists the names of the folders in your folder directory. |
followup [message] | (fo) Responds to a message, recording the response in a file whose name is derived from the author of the message. Overrides the record variable, if set. |
Followup [MessageList] | (F) Responds to the first message in the msglist, sending the message to the author of each message in the msglist. The subject line is taken from the first message and the response is recorded in a file whose name is derived from the author of the first message. |
from [MessageList] | (f) Displays the headings of messages in MessageList. |
group | (g) Identical to the alias subcommand. |
headers [Message] | (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). If the mailbox contains more messages than can be displayed on the screen at one time, information about only the first group of messages will be displayed. To see information about the rest of the messages, use the h subcommand with a message number in the next range of messages, or use the z subcommand to change the current message group. |
help | Displays a brief summary of mailbox subcommands. Identical to the ? subcommand. |
hold [MessageList] | (ho) Marks each message in MessageList to be saved in your system mailbox (/var/spool/mail/UserID) instead of in your $HOME/mbox file. Does not override the delete subcommand. Identical to the preserve subcommand. |
if Condition |
else | |
endif | Construction for conditional execution of the mail
subcommands. Subcommands following if are executed if
Condition is true. Subcommands 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).
|
| [[msglist] command]] | (pi) Pipe the messages through the given command by invoking the command interpreter specified by SHELL with two arguments: -c and command. The command must be given as a single argument. This can be accomplished by quoting. If no arguments are given, the current message will be piped through the command specified by the value of the cmd variable. If the page variable is set, a form-feed character will be inserted after each message. |
preserve | (pre) Identical to the hold subcommand. |
print [MessageList] | (p) Displays the text of a specific message. Identical to the type subcommand. |
Print [MessageList] | (P) Displays the text of a specific message along with the ignored header fields. Identical to the Type subcommand. |
quit | (q) Leaves the mailbox and returns to the operating system. All messages read, but not deleted or saved are stored in your personal mailbox ($HOME/mbox). All messages you have marked to be deleted are removed from the mailbox and cannot be recovered. All messages marked with the hold or preserve option and messages you have not viewed are saved in the system mailbox (/var/spool/mail/UserID). If the quit subcommand is given while editing a mailbox file with the -f flag, the edit file is saved with changes. If the edit file cannot be saved, the Mail program does not exit. Use the exit subcommand to exit without saving the changes. |
reply [Message] | (r) Allows you to reply to the sender of a message and to all others who receive copies of the message. Identical to the respond subcommand. |
Reply [Message] | (R) Allows you to reply to only the sender of a message. Identical to the Respond subcommand. |
respond [Message] | Allows you to reply to the sender of a message and to all others who receive copies of a message. Identical to the reply subcommand. |
Respond [Message] | Allows you to reply to only the sender of a message. Identical to the Reply subcommand. |
retain [FieldList] | Adds the header fields in FieldList to the list of fields to
be retained. Retained fields are displayed when you look at a message
with the type subcommand or print
subcommand. Use this subcommand to define which header fields you want
displayed. Use the Type or
Print subcommand to print a message in its entirety, including
fields that are not retained. If the retain subcommand is
executed with no arguments, it lists the current set of retained
fields.
Note: The retain subcommand overrides the discard subcommand. |
save [ File ] | (s) Saves the current message including header information to a file or folder. If the file already exists, the message is appended to the file. If File is omitted, the message will be saved to the user's mbox. |
save [MessageList] File | (s) Saves a MessageList including heading information to a file or folder. If the file already exists, the MessageList is appended to the 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 (/var/spool/mail/UserID) nor saved in your personal mailbox ($HOME/mbox) when you quit the Mail program. |
Save [MessageList] | (S) Saves the specified messages in a file whose name is derived from the author of the first message. The name of the file is taken to be the author's name with all network addressing stripped off. |
set [OptionList | Option=Value...] | |
(se) With no arguments, displays the options that are
currently enabled. Otherwise, sets an option as specified. The
argument following the set command can be either:
The options are listed in the .mailrc file format.
Note: The form unset name is equivalent to noname. | |
shell | (sh) Starts an interactive version of the shell. |
size [MessageList] | Displays the sizes in lines/characters of the messages in MessageList. |
source File | (so) Reads and executes the mail subcommands from File. |
top [MessageList] | Displays the top few lines of the messages specified by MessageList. The number of lines displayed is determined by the valued option toplines and defaults to five. |
touch [MessageList] | Within your system mailbox (/var/spool/mail/UserID), this subcommand marks the messages in MessageList to be moved to your personal mailbox ($HOME/mbox) when you quit the Mail program. The messages are moved even though you have not read them. The messages are displayed in your personal mailbox as unread messages. The last message in MessageList becomes the current message. |
type [MessageList] | (t) Displays the text of a specific message. Identical to the print subcommand. |
Type [MessageList] | (T) Displays the text of a specific message along with the ignored header fields. Identical to the Print subcommand. |
unalias | Deletes the specified alias names. |
undelete [MessageList] | (u) Removes the messages in MessageList from the list of messages to be deleted when you quit the Mail program. Entering the u subcommand without a message list recalls the last deleted message. |
unread [MessageList] | (U) Marks each message in MessageList as not having been read. Identical to the new, New, and Unread subcommands. |
Unread [MessageList] | Marks each message in MessageList as not having been read. Identical to the new, New, and unread subcommands. |
unset OptionList | Disables the values of the options specified in
OptionList. This action is the inverse of the set subcommand.
Note: The form unset name is equivalent to noname. |
version | (ve) Displays the version banner for the Mail program. |
visual [MessageList] | (v) Starts the visual editor using the MessageList as the input field. (This editor can be defined with the set VISUAL= statement.) Any changes made during the editor session are saved back to the messages in the MessageList. |
write [MessageList] File | (w) Saves a message without heading information to a file or folder. 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 subcommand. |
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 given, then headings in the next group are shown. If a - argument is given, the headings in the previous group are shown. |
By default, the Mail program
treats lines beginning with the ~ (tilde) character as subcommands. The
following list describes the subcommands used while in the mail editor.
The editor recognizes subcommands only if you enter them at the beginning of a
new line.
~? | Displays a summary of the mail subcommands. |
~!Command | The command interpreter specified by SHELL will be invoked with two arguments: -c and command. The standard output of command will be inserted into the message. |
~a | Inserts the value of the sign variable into the text of the message, followed by a newline character. Identical to ~i sign. |
~A | Inserts the value of the Sign variable into the text of the message, followed by a newline character. Identical to ~i Sign. |
~b AddressList | Adds names in AddressList to the list of addresses to receive blind copies of the message. The ~b subcommand can only be used to add to, not change or delete, the contents of the Bcc: List. |
~c AddressList | Adds names in AddressList to the list of people to receive copies of the message. The ~c subcommand can only be used to add to, not change or delete, the contents of the Cc: List. |
~d | Appends the contents of the dead.letter file to the end of the message. |
~e | Starts the alternate editor using the message text as the input file. (This editor can be defined with the set EDITOR= statement in the Bourne shell.) When you exit that editor, you return to the mail editor, where you may add text, or send the message by exiting the Mail program. |
~f [MessageList] | Includes a MessageList in the current message to forward the message to another user. This subcommand reads each message in the MessageList and appends it to the current end of the message, but does not indent the appended message. This subcommand is also used to append messages for reference whose margins are too wide to embed with the ~m subcommand. This subcommand works only if you entered the mail editor from the mailbox prompt using either the mail, reply, or Reply subcommand. |
~F [MessageList] | Equivalent of the ~f, except that all headers will be included in the message, regardless of previous discard, ignore, and retain commands. |
~h | Enables you to add or change information in all of the heading fields. The system displays each of the four heading fields, one at a time. You can view the contents of each field and delete or add information to that field. Press the Enter key to save any changes to the field and to display the next field and its contents. |
~i string | Inserts the value of the named variable, followed by a newline character, into the text of the message. If the string is unset or null, the message will not be changed. |
~m [MessageList] | Includes a MessageList in the current message for reference purposes. This subcommand reads each message in the MessageList and appends it to the current end of the message. The included message is indented one tab character from the normal left margin of the message. This subcommand works only if you entered the mail editor from the mailbox prompt using either the mail, reply, or Reply subcommand. |
~M [MessageList] | Equivalent of the ~m, except that all headers will be included in the message, regardless of previous discard, ignore, and retain commands. |
~p | Displays the entire message, including header information. |
~q | Quits the editor without sending the message. Saves the message in
the dead.letter file in your home directory, unless the
nosave option is set. The previous contents of the
dead.letter file are replaced with the partially completed
message.
Note: You can also quit the editor by using the Interrupt (Ctrl-C) key sequence twice. |
~r File | Reads the contents of a file into the current message. |
~s String | Changes the subject field to the phrase specified in String. You cannot append to the subject field with this subcommand. |
~t AddressList | Adds the addresses in AddressList to the To: field of the message. The ~t subcommand can only be used to add to, not change or delete, the contents of the To: List. |
~v | Starts the visual editor using the message text as the input file. This editor can be defined with the set VISUAL= statement in the Bourne shell.) When you exit that editor, you return to the mail editor where you may add text to the message, or send the message by exiting the Mail program. |
~w File | Writes the message to the named file. |
~x | Exits as with ~q, except the message will not be saved in the dead.letter file. |
~: Subcommand | Executes the subcommand specified by Subcommand and returns to the mail editor. |
~| Command | Pipes the message through the command Command as a filter. If Command gives no output or terminates abnormally, it retains the original text of the message. Otherwise, the output of Command replaces the current message. The fmt command is often used as Command to format the message. |
~< file | Reads the contents of a file into the current message. |
~<!Command | Allows you to run a shell command. The shell runs with the -c flag and the Command specified. The standard output of Command is inserted into the message. |
~~ | Allows you to use the ~ (tilde) character in a message without it being interpreted as a command prefix. The ~~ key sequence results in only one ~ character being sent in the message. |
The bellmail command, fmt command, pg command, sendmail command.
The .mailrc file format.
Mail Overview, Creating and Sending Mail, Receiving and Handling Mail in AIX 5L Version 5.1 System User's Guide: Communications and Networks.
Reading Mail, Replying to Mail, Displaying the Contents of Your Mailbox, Editing a Message, Folders in AIX 5L Version 5.1 System User's Guide: Communications and Networks.
Customizing the Mail Program, Starting the Mail Editor, Displaying a Message While in the Mail Editor, Changing or Adding to the Heading Fields of a Message in AIX 5L Version 5.1 System User's Guide: Communications and Networks.
Checking for Misspelling in the Mail Editor, Reformatting a Message in the Mail Editor, Changing Text Editors Used for Entering Messages in AIX 5L Version 5.1 System User's Guide: Communications and Networks.
Mailbox Subcommands for the mail Command .