When you have several messages in your mailbox, the displayed list might not show all of your mail. If this situation applies, type:
To view the current message in the mailbox list (marked with >), press Return. Press Return again to display the next message. To read any message in the list, type its number and press Return.
Deleting (and Undeleting) Messages
After you have read a message, you might decide to delete it rather than save it to your mbox file. A save to the mbox file is the default when you quit the mailx program.
To delete the last message you read, just type d at the mailx prompt. To delete a specific message from your mailbox, use the command form:
d number
For example, to delete the second message, use this command from within mailx:
& d 2 |
You can also delete several messages at a time. To delete messages 1 and 3, use the command:
& d 1 3 |
To delete a range of messages, for example 1 through 3, use the command:
& d 1-3 |
Before you quit mailx, you can undelete messages you've removed from your mailbox. Use the command form:
u number
followed by Return. For example, to undelete the second message, use this command:
& u 2 |
To undo your last deletion, just type u at the mailx prompt immediately after the deletion. For example, if your last deletion command was d 2-5, type u to undelete messages 2, 3, 4, and 5.
Note that all deletions are made permanent when you quit mailx with the q command. That is, you can no longer undelete messages that have been deleted. You can, however, quit mailx with the x command and leave your mailbox intact. As mentioned previously, if you quit with x you leave read messages marked with a U, deleted messages undeleted, and so forth.
Printing Messages
You can print a hard copy of a message by piping a message to a printer command. To do so, use the following command form at a mailx prompt:
|number lp
The | symbol is called a pipe. For example, to print a copy of message 2, type:
& |2 lp |
Then press Return. If a message number is not specified, mailx pipes the current message to the printer. For more information on piping, see "Redirecting and Piping Command Output".
Sending Messages
To send mail with the mailx program, you need to know the login name(s) of the intended recipient(s) of your message. If an intended recipient is on a different machine, you also need to know that user's machine name. To determine this information, you can use the who, finger, or rusers commands.
Type the who command to list all the users who are currently logged in to the file server you are on. The displayed list contains users' login names, their terminal types, and the date and time they logged in. For example:
$ who elmer tty15 Feb 20 10:22 susan tty04 Feb 20 10:37 stormy tty07 Feb 20 11:49 hankw tty06 Feb 20 12:02 |
Type the finger command to display the same type of information as who with more detail. The information that appears depends on how your system administrator has set up this command. As an example, you might see something like the following:
$ finger Login Name TTY Idle When elmer Elmer Brown tty15 43 Thu 10:22 susan Susan Lake tty04 Thu 10:37 stormy Stormy Ball tty07 12 Thu 11:49 hankw Hank Wilson tty06 22 Thu 12:02 |
The rusers command provides information on the users who are currently logged in to your local network. Refer to Chapter 9, Using the Network for instructions on the use of the rusers command.
When you have determined the necessary user information, complete the following steps to send a message.
Type the mailx command, followed by a user's address:
$ mailx user@machine
In this command, user is the intended recipient's login name and machine is the name of the intended recipient's machine.
If you've already started mailx, you can just type m at the mailx prompt, followed by the intended recipient's login and machine name:
& m user@machine
To send the same message to multiple recipients, separate each address with a space or a comma, for example:
$ mailx hank@fretful sally@dakota tex@twister
or
$ mailx hank@fretful,sally@dakota,tex@twister
When you press Return, the mailx program prompts you for a subject. Type a subject for your message and press Return again.
Type the body of your message. To create a new line, press Return.
A sentence that wraps on your screen is not considered a new line until you press Return.
Note - Each line of text within your message can be up to 256 characters long. When you exceed this limitation, your screen freezes. If this situation occurs, press Ctrl-C to abort your message.
When you have completed your message, press Return to move the cursor to a new line. Then press Ctrl-D to send your message.
Undeliverable Messages
If you specify an incorrect user address when you send a message, the system responds with the message
user@machine...User unknown
The message is then returned to your mailbox. The next time you type the mailx command, the header states that you have returned mail, similar to the following example:
N 1 Mailer-Daemon Fri Jan 3 11:13 8/49 Returned mail: User unknown |
When a message cannot be delivered, the file is also copied to a file in your home directory named dead.letter.
Canceling an Unsent Message
You can cancel a message at any time before it is sent by pressing Ctrl-C twice.
Adding Carbon and Blind Carbon Copies
Before sending a message, you can specify that "carbon copies" be sent to other than the main addressees. You can also send "blind carbons." This specification ensures that recipients of your message can read the addresses for the carbon copies, but not the addresses for the blind carbons.
Many people send themselves carbons or blind carbons in order to retain a copy for their own record.
You can use three methods for sending carbon copies with a message:
Use a text editor to edit your .mailrc file (in your home directory) and insert the following line:
set askcc
The mailx program now displays the carbon copy prompt (Cc:) after the subject prompt. Type the addresses of the users you want to receive carbon copies. Separate multiple addresses with spaces.
When you have typed the body of your message, but before you press Ctrl-D, press Return to move to a new line and use the command form:
~c address(es)
To use this method to send carbon copies to multiple recipients, separate the addresses with spaces. For example:
~c hank@fretful george@lonesome stormy@snoozer |
You can also create a Cc: line with the ~h command, which displays the entire header of the message. ~h prompts you with To:, Subject:, Cc:, and Bcc: (blind carbon copy) lines, one line at a time. You can fill in blank lines. You can also retype filled lines. As with other tilde commands, always use the ~h command on a new line.
Note - ~c, ~h, and other tilde commands are described in "Tilde Commands".