[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 System User's Guide: Communications and Networks

Receiving and Handling Mail

The mail program enables you to examine each message in a mail box and then delete or file a message in a personal mail directory. This section discusses the concepts and procedures on the following mail tasks:

Starting the Mail Program

When mail is sent to your address, it is stored in a system directory that is specifically for mail. This system directory contains a file for every user on the local system. This directory holds your mail until you do something with it.

The command shell notifies you that mail has arrived. The notification is displayed before the next prompt, provided that the MAIL environment variable is set and provided that the interval specified by MAILCHECK has elapsed since the shell last checked for mail. The notification message is the value of the MAILMSG environment variable. Depending on which shell you are using (bourne, korn, or C shell), the notification is similar to the following:

YOU HAVE NEW MAIL

Use the mail command to read and remove messages from your system mailbox. Do not use the system mailbox to store messages. Store messages in your personal mailbox ($HOME/mbox) and in folders.

Prerequisites

The mail program must be installed on your system.

To Check Your System Mailbox

At your system command line prompt, enter the mail command:

mail

If there is no mail in your system mailbox, the system responds with a message:

No mail for YourID

If there is mail in your mailbox, the system displays a listing of the messages in your system mailbox:

Mail Type ? for help.
"/usr/mail/lance": 3 messages 3 new
    >N       1 karen Tue Apr 27 16:10 12/321 "Dept Meeting"
     N       2 lois  Tue Apr 27 16:50 10/350 "System News"
     N       3 tom   Tue Apr 27 17:00 11/356 "Tools Available"

The current message is always prefixed with a > (greater-than symbol). Each one-line entry displays the following fields:

status Indicates the class of the message.
number Identifies the piece of mail to the mail program.
sender Identifies the address of the person who sent the mail.
date Specifies the date the message was received.
size Defines the number of lines and characters contained in the message (this includes the header).
subject Identifies the subject of the message, if it has one.

The status can be any of the following:

N A new message.
P A message that will be preserved in your system mailbox.
U An unread message. This is a message that was listed in the mailbox the last time you used the mail program, but the contents were not examined.
* A message that was saved or written to a file or folder.

A message without a status indicator means that the message has been read but has not been deleted or saved.

To Check Your Personal Mailbox or Mail Folder

At your system command line prompt, you can use the mail command in the ways shown in the following examples:

mail -f A listing of the messages in your personal mailbox, $HOME/mbox, is displayed.

If there is no mail in your personal mailbox, the system responds with the message:

"/u/george/mbox": 0 messages

OR

A file or directory in the path name does not exist
mail -f +dept In this example, a listing of the messages in the dept folder is displayed.

If there is no mail in your mail folder, the system responds with the message:

A file or directory in the path name does not exist

Displaying the Contents of Your Mailbox

From the mailbox prompt you can enter mailbox subcommands to manage the contents of the mailbox.

Prerequisites

  1. The mail program must be installed on your system.
  2. The mail program must be started.
  3. There must be mail in your mailbox.

To Display a Message within a Specific Range of Messages

The (h)eaders subcommand allows you to view a message contained within a specific range of messages. At your mailbox prompt, you can use the h subcommand in the ways shown in the following examples:

h Approximately 20 messages are displayed at a time. The actual number displayed is determined by the type of terminal being used, and the set screen option in your .mailrc file. If you enter the h subcommand again, the same range of messages are displayed.
h 21 Message 21 and subsequent messages, up to and including message 40 (if you have that number of messages in your mailbox), are displayed. Continue entering the h subcommand with the subsequent message number until all messages have been displayed.
h 1 To return to the first group of 20 messages, enter any number within the range of 1-20.

To Scroll Your Mailbox

The z subcommand allows you to scroll your mailbox. At your mailbox prompt, you can use the z subcommand in the ways shown in the following examples:

z Approximately 20 messages are displayed at a time. The actual number displayed is determined by the type of terminal being used and the set screen option in your .mailrc file. Enter the z subcommand again to scroll to the next 20 messages.
z + The + (plus) argument scrolls to the next 20 messages. Message 21 and subsequent messages, up to and including message 40 (if you have that number of messages in your mailbox), are displayed. Continue entering the z+ subcommand until all messages have been displayed. The system will respond with the following message:
On last screenful of messages.
z - The - (minus) argument scrolls to the previous 20 messages. When you reach the first set of messages, the system will respond with the following message:
On first screenful of messages.

To Search and Display Information about Specific Messages

At your mailbox prompt, you can use the (f)rom subcommand in the ways shown in the following examples:

f Displays heading information for the current message.
f 1 4 7 Displays heading information for the specific messages 1, 4, and 7.
f 1-10 Displays heading information for a range of messages 1 through 10.
f * Displays all messages.
f ron Messages, if any, from user ron are displayed. The characters entered for an address do not need to match exactly the address; therefore, the request for address ron in either uppercase or lowercase letters matches all of the following addresses:
RoN
ron@topdog
hron
rOn
f /meet Messages, if any, where the Subject: field contains the letters meet are displayed. The characters entered for a pattern do not need to match exactly the Subject: field. They must only be contained in the Subject: field in either uppercase or lowercase letters; therefore, the request for subject meet matches all of the following subjects:
Meeting on Thursday
Come to meeting tomorrow
MEET ME IN ST. LOUIS

To Display the Current Message Number

At your mailbox prompt, you can use the = subcommand in the way shown in the following example:

= The current message number is displayed.

To Check How Many Messages You Have in Your Mailbox

At your mailbox prompt, you can use the folder subcommand in the way shown in the following example:

folder Lists information about your folder or mailbox. The system will respond with similar to the following:
"/u/lance/mbox": 29 messages.

Reading Mail

You can read your mail in several ways. The following provides an example of each method. Choose the method you are most comfortable with and use it to read your mail.

Prerequisites

  1. The mail program must be installed on your system.
  2. The mail program must be started.
  3. There must be mail in your system mailbox.

To Read Messages in Your Mailbox

At your mailbox prompt, you can use the (t)ype or (p)rint subcommands in the ways shown in the following examples:

3 If you use the number of the message, by default, the text of the message is displayed.
t If you use the t subcommand, by default, the text of the current message is displayed.
t 3 The text of message 3 is displayed.
t 2 4 9 The text for messages 2, 4, and 9 is displayed.
t 2-4 The text for the range of messages 2 through 4 is displayed.
p If you use the p subcommand, by default, the text of the current message is displayed.
p 3 The text of message 3 is displayed.
p 2 4 9 The text for messages 2, 4, and 9 is displayed.
p 2-4 The text for the range of messages 2 through 4 is displayed.

When you display more than one message at a time, be sure to include the set crt option in your $HOME/.mailrc file so you can scroll through your messages. You also can enter this subcommand at the mailbox prompt. If you do not use this subcommand and you have more than one screen of messages, the displayed messages scroll up and off the screen before you have time to read them.

To Read the Next Message in Your Mailbox

At your mailbox prompt, you can use the (n)ext or + subcommands in the way shown in the following example:

n or + Displays the text of the next message, and this message becomes the current message.

You can also press the Enter key to display the text of the next message.

To Read the Previous Message

At your mailbox prompt, you can use the - subcommand in the way shown in the following example:

- The text of the previous message is displayed.

Deleting Mail

When deleting a message, you can delete the current message, delete a specific message, or delete a range of messages. You can also delete the current message and display the next message by combining subcommands.

Prerequisites

  1. The mail program must be installed on your system.
  2. There must be mail in your system mailbox.
  3. The mail program must be started.

To Delete a Message

At your mailbox prompt, you can use the (d)elete subcommand in the ways shown in the following examples:

d The current message is deleted.
dp or dt The current message is deleted and the next message is displayed. This also can be accomplished by including the set autoprint option in the .mailrc file, which will set the d subcommand to function like the dp or dt subcommand combination.
d 4 Deletes the specific message 4.
d 4-6 Deletes a range of messages 4, 5, and 6.
d 2 6 8 Deletes messages 2, 6, and 8.

To Undelete a Message

At your mailbox prompt, you can use the (u)ndelete subcommand in the ways shown in the following examples:

u The current message is undeleted.
u 4 Undeletes the specific message 4.
u 4-6 Undeletes a range of messages 4, 5, and 6.
u 2 6 8 Undeletes messages 2, 6, and 8.

Exiting Mail

Prerequisites

  1. The mail program must be installed on your system.
  2. There must be mail in your system mailbox.
  3. The mail program must be started.

To Exit Mail and Save Your Changes to the Original Contents of the Mailbox

At your mailbox prompt, you can use the (q)uit subcommand in the following ways shown:

If You Are Exiting the System Mailbox:

q The q subcommand leaves the system mailbox and returns to the operating system. When you leave the mailbox, all messages marked to be deleted are removed from the mailbox and cannot be recovered. The mail program saves the messages you read in your personal mailbox (mbox). If you did not read any of your mail, the messages remain in the system mailbox until acted upon.

If You Are Exiting Your Personal Mailbox or a Mail Folder:

q When using the q subcommand in your personal mailbox or a mail folder, messages read and not read will remain in your personal mailbox or in a mail folder until acted upon.

To Exit Mail without Changing the Original Contents of the Mailbox

x or ex The x or ex subcommand allows you to leave the mailbox and return to the operating system without changing the original contents of the mailbox. The program ignores any requests you made prior to the x request; however, if you did save a message to another folder, the save will occur.

Organizing Mail

Use folders to save messages in an organized fashion. You can create as many folders as you need. Give each folder a name that pertains to the subject matter of the messages it contains, similar to file folders in an office filing system. Each folder is a text file that is placed in the directory you specify in your .mailrc file with the set folder option. You must create this directory before using folders to store messages. Once the directory exists, the mail program creates the folders in that directory as needed. If you do not specify a directory with the set folder option in your .mailrc file, the folder is created in your current directory. Using the mail program, you can put a message into a folder from the system mailbox, a personal mailbox, or another folder.

You can add the contents of a message to a file or folder using the (s)ave or (w)rite subcommands. Both of these subcommands append information to an existing file, or create a new file if it does not exist. Information currently in the file is not destroyed. If you save a message from your system mailbox to a file or folder, the message is deleted from your system mailbox and transferred to the file or folder specified. If you save a message from your personal mailbox or folder to another file or folder, the message is not deleted from your personal mailbox, but is copied to the specified file or folder. When using the s subcommand, you can read the folder like a mailbox because the messages and the header information are appended at the end of the folder. When using the w subcommand, you can read the folder like a file because the message is appended without header information at the end of the file.

Prerequisites

  1. The mail program must be installed on your system.
  2. There must be mail in your system mailbox, personal mailbox, or a folder you have defined.
  3. The mail program must be started.

To Create a Letters Mailbox Directory to Store Messages in Folders

  1. To check if the set folder option has been enabled in the .mailrc file, enter the following subcommand at the mailbox prompt:
    set
    The set subcommand displays a list of the enabled mail options in your .mailrc file.

    If the set folder option has been enabled, the system responds with a message similar to the following:

    folder /home/george/letters
    In this example, letters is the directory in which mail folders will be stored.

  2. If the set folder option has not been enabled, add a line similar to the following in the .mailrc file:
    set folder=/home/george/letters
    In this example, /home/george is George's home directory and letters is the directory in which mail folders will be stored. The set folder option enables you to use the + (plus sign) shorthand notation at your mailbox prompt to save messages in your letters directory.

  3. You must create a letters directory in your home directory. In your home directory at the system command line prompt, enter:
    mkdir letters

To Use the (s)ave Subcommand to Save a Message with Its Heading

At your mailbox prompt, you can use the (s)ave subcommand in the ways shown in the following examples:

s 1-4 notes Saves messages 1 , 2 , 3 and 4 with their heading information to a folder called notes in the current directory.

The mail program responds with the following message:

"notes" [Appended] 62/1610
s +admin Saves the current message to an existing folder called admin in your folder directory.

If the folder directory is defined as /home/george/letters in your .mailrc file, the system responds with:

"/home/george/letters/admin" [Appended] 14/321
6  +admin Saves message 6 to an existing folder called admin in your folder directory.

If the folder directory is defined as /home/george/letters in your .mailrc file, the system responds with:

"/home/george/letters/admin" [Appended] 14/321

To Use the (w)rite Subcommand to Save a Message without Its Heading

The (w)rite subcommand allows you to save a message as a file instead of as a folder. To read or edit a file saved with the w subcommand, you must use vi or some other text editor. At your mailbox prompt, you can use the w subcommand in the ways shown in the following examples:

6 pass Saves only the text of message 6 to a file called pass in the current directory.

If the pass file does not already exist, the system responds with the following message:

"pass" [New file] 12/30

If the pass file exists, the system responds with the following message:

"pass" [Appended] 12/30
1-3 safety Saves only the text of the specific messages 1 , 2 , and 3 to a file called safety in the current directory.

The text of the messages in this example will be appended one after the other into one file. If the safety file does not already exist, the system responds with the following message:

"safety" [New file] 12/30

To Find the Name of the Current Mailbox or Folder

Although the mail command displays the name of the current mailbox when it starts, you may lose track of which mailbox you are in. At your mailbox prompt, you can use the folder subcommand in the way shown in the following example:

folder Finds the name of your current mailbox or folder.

If the current mailbox is /home/lance/mbox, the following is displayed:

/home/lance/mbox: 2 messages 1 deleted

This message indicates that /home/lance/mbox is the current mailbox you are in, it contains two messages, and one of those messages will be deleted when you finish with this mailbox.

To Change to Another Mailbox

Changing to another mailbox is like quitting a mailbox or folder. Any messages that you marked to be deleted are deleted when you leave that mailbox. The deleted messages cannot be recovered. At your mailbox prompt, you can use the file or folder subcommand in the way shown in the following example:

folder +project Once the mail program is started with one mailbox, use the file or folder subcommands to change to another mailbox.

If you change from the mbox file to the project folder and you have deleted all the messages in the mbox file, the mail program displays:

/home/dee/mbox removed
+project: 2 messages 2 new

followed by a list of the messages in the project folder.

Related Information

Summary of System commands to Execute Mail

Summary of Mailbox Subcommands in the Mail Program

Customizing the Mail Program

Changing the Number of Message Headers or Message Text Lines Displayed in the Mail Program

Controlling What Information Is Displayed


[ Previous | Next | Contents | Glossary | Home | Search ]