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:
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.
The mail program must be installed on your system.
At your system command line prompt, enter the mail command:
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:
The status can be any of the following:
A message without a status indicator means that the message has been read but has not been deleted or saved.
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 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 |
From the mailbox prompt you can enter mailbox subcommands to manage the contents of the mailbox.
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 is 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. |
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:
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 exactly match 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 exactly match 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 |
At your mailbox prompt, you can use the = subcommand in the way shown in the following example:
= | The current message number is displayed. |
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 similarly to the following:
"/u/lance/mbox": 29 messages. |
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.
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.
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.
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. |
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.
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. |
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. |
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. |
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. |
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.
setThe 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/lettersIn this example, letters is the directory in which mail folders will be stored.
set folder=/home/george/lettersIn 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.
mkdir letters
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 |
s 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 |
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:
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. |
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:
Summary of System commands to Execute Mail
Summary of Mailbox Subcommands in the Mail Program
Changing the Number of Message Headers or Message Text Lines Displayed in the Mail Program
Controlling What Information Is Displayed