OpenWindows Advanced User's Guide

7.1 mailx Basics

In this section you will learn just enough about mailx to get by. In later sections you will learn about features and functions that will greatly enhance your ability to use this program.

An intended recipient's login name and machine name serve as a unique address for the mailx program. If the intended recipient is on the same machine as the sender, the login name is all that is required. Each user has a mailbox in which to receive mail. This mailbox is generally located in the /var/mail/username directory, where username is your login name.

The mailx program notifies you when you receive mail and places the mail in your mailbox. After you've read your mail, mailx automatically places these letters in a storage file called mbox, which is also located in your home directory.

7.1.1 Starting mailx

Start mailx by typing the following command at a prompt and then pressing the Return key:

$ mailx

If you don't have any mail waiting for you, your terminal will display the message:

No mail for username$

where username is your login name.

7.1.2 Sending Yourself a Sample Letter

To see at a glance how mailx works, you can begin by sending yourself a sample letter. At the prompt, give the mailx command again, but this time include your address (your login name plus your machine name). For example, if your login was rose and your machine name was texas, your address would be rose@texas. (The @ symbol is read as "at.") You may be able to use just your login on a local network--consult your system administrator when in doubt.

$ mailx rose@texas

The program will respond with a Subject: line:

$ mailx rose@texas
Subject:

If you like, type in a word or two here about the content of the letter you're sending yourself and press Return. Now type the body of the letter; use short lines and press Return at the end of each line. (Note that you can only make corrections as you go by backspacing and retyping lines before you press Return.)

Your sample letter might look something like this (the spaces between lines are made by pressing Return twice):

$ mailx rose@texas
Subject: to someone who really cares

Dear Rosey,

From the ends of your fingers
To the tip of your nose
You're a cool breeze in August
My sweet Texas Rose.


See you soon,

Rose

To send your sample letter, press Return to complete the last line of the letter and then press Ctrl-D. After your letter has been sent, the system returns a command prompt.

7.1.3 Reading Your Sample Letter

To read your sample letter, give the mailx command again. Your screen will probably look something like this:

$ mailx
Mail version 4.0 Thu Jan 16 12:59:09 PST 1992  Type ? for help.
"/var/mail/rose": 2 messages 1 new
 U  2 hal@uncertain   Fri Feb 14 12:01   14/318 financial status
>N  1 rose@texas      Mon Feb 17 08:12   21/453 to someone who
&

The first line identifies the version of mail that you are running; the second line indicates your mailbox, usually located in /var/mail/username, where your incoming mail is deposited. The third line in this example is the header of the letter you sent yourself. The "N" at the beginning of the line means that it's a "new" letter. A "U" (unread) means the letter was new, but was not read before quitting the mailx program previously. (The information in this screen is discussed in greater detail in "7.2 Reading Letters", in this chapter.)

Every letter is assigned a number as it is received: Rose's letter to herself is shown as letter number 1.

To read a letter, type its number at the mailx prompt, the ampersand (&), as follows:

$ mailx
Mail version 4.0 Thu Jan 16 12:59:09 PST 1992  Type ? for help.
"/var/mail/rose": 1 message 1 new
>N  1 rose@texas   Fri Jul 14 12:01 21/453 to someone who
& 1

To: rose@texas
From: rose@texas
Subject: to someone who really cares

Dear Rose,

From the ends of your fingers
To the tip of your nose
You're a cool breeze in August
My sweet Texas Rose.


See you soon,

Rose

&

7.1.4 Quitting mailx

When you're finished using mailx, you can quit the program using one of two commands: q (quit) or x (exit).

If you type q at the mailx prompt and then press Return,

& q

you will then see a message similar to the following:

Saved one message in home_directory/mbox.

where home_directory is the path name to your home directory.

When you use q to quit mailx after reading messages, mailx moves the letters from your mailbox and saves them in the mbox file in your home directory. mailx also saves any changes or deletions you've made.

If you type x at the mailx prompt and then press Return,

& x

the mailx program does not save any changes or deletions, nor does it move any letters you've already read into the mbox file.