Mail Manual for HP-UX Unix

[NOTES:]
[Text in bold/italics is what you are to type]
[Text in underlined italics the machine prints on the screen]
[<cr> means to hit the carriage return, % is the "shell" and & is the mail prompt]
  1. Reading Your Mail
  2. Sending Mail
  3. Reading Files of Saved Messages
  4. HOW TO RESEND OR FORWARD MAIL
  5. How to Mail a File

This is a quick lesson in the use of the "mail" utility.[*] It will not show you all the potential or possibilities of the program. Rather, it is intended to get you to the point where you can read and answer your mail and to provide a reminder of the various functions of the mail program.

Reading Your Mail

To get into the mail program type:

% mail <cr>

The first thing you will see will be a list of "headers". These tell you who sent the message, when it was sent and how many lines/characters it contains. The mail prompt is a question mark "&". To read your mail type <cr> at the &. Your messages will be presented to you in order.

To read each message, hit the <cr>.

To read the next screen of a long message, hit the space bar.

Sending Mail

To send mail type :

% mail username <cr>

Where "username" is the account of the person you want to send mail to.

The machine will prompt you for a subject line. It's optional but useful for your reader. Then, after you hit the return on the subject line, the screen is ready for you to type your message. REMEMBER, the machine does not break the lines at the end of the screen like a word processor. You have to watch the screen and do it for yourself. At the end of the message you send the mail with a Control D (^D) on a line by itself. The machine will ask if you want to send a "Carbon Copy" to someone else:

Cc: [username]

If so, type their account number (username) or alias. If not, just hit the return.

Reading Files of Saved Messages

% mail -f filename -- reads a file with the mail program (so that it "looks" like mail).

MAIL COMMANDS

The prompt inside the mail program is a Question-mark (&).

At the "&", you may respond to a message by typing:

& r

which sends your response to all recipients of the original message or
& R

which sends your reponse to the original sender only.

You may also send mail with:

& m username

If you want to return to the list of headers, type:

& h

If you wish to see a particular message, type its number:

& 5

&s filename -- saves message in a file instead of the mbox

&dp -- deletes just-read message, prints next message

&pre -- "preserves" (keeps) the message(s) in your mail spool

When you are done with the mail program type:

& q

All your mail will be saved in your "mbox" file.

[NOTE: do not exit the mail program with the "x" command.

This leaves the mail spool unchanged and will create difficulties for you later]

The next set of commands are called "escapes". Used with the "tilde" (~) character they allow the user to mix the file system and the editors with the mail program.

~r filename -- copies file into outgoing message

~v -- allows editing the outgoing message with the "vi" editor

~f -- "forwards" the current message with the outgoing message

HOW TO RESEND OR FORWARD MAIL

Scenario #1: you sent a message and, for whatever reason (usually a bad address line) it failed to go through. You want to resend it without having to type it in all over again, and the message is sitting either in your mail or in your mbox, having been returned by the dread MAILER- DAEMON.

Scenario #2: you have a message, sent to you by someone and you wish to forward it to someone else. The message in question is either in your mail or in your mbox.

What you are going to do is get into the appropriate mail file, locate the appropriate message, fire up a sendmail to the appropriate person or persons (in the case of a mailist), append your chosen message to the outgoing message body (with or without additional text), fire up the vi editor and trim the header down or off, end the editor session and return to sendmail, send the message. Viz:

1. Get into mail or your mbox (mail -f mbox) and figure out which message you wish to resend/forward. At the & type
h to see the list of headers. Pick the message you wish to forward.

2. At the & type "mail" and the address of the person you wish to send the mail to.

& mail za12@sdcc4

3. Hit the return and fill in the requested "Subject" line:

Subject: Mail from the void

4. Hit the return two more times.

5. On a new, blank line (which you got with the two returns), type ~f and the number of the message you wish to forward.

~f 3

Sendmail will tell you that it has "interpolated" the message.

Interpolating: 3
(continue)

At this point if you are in a hurry you can just type a Control-D and send the message. However, if you care about your readers and don't wish to send them extra screenfuls of old headers, or if you want to add your own commentary to the outgoing text, you can edit the outgoing message file to remove unwanted, unnecessary lines.

When sendmail tells you (continue), type ~v and bring the message up in the vi editor.

First, to get those "greater-than" signs (>) in front of all lines in the message, you are going to use the global search and replace command. Type:

:g/^/s//>/

(Literally, colon g slash carat slash s slash slash greater-than slash)

Assuming you did everything correctly, the colon and the rest of the command will appear at the bottom, left corner of the screen. When you hit the return, your file will have > signs all down the left hand side.

Next you want to delete as much of the old message as possible (no need to clutter up your reader's screen with a bunch of pointless junk -- succienctness is next to goodliness :-)

The editor command "dd" removes lines. The "j" and "k" keys allow you to move the cursor up and down in the file. Using a combination of the above keystrokes, move through the file, deleting lines like: Received-From, Transcript of Session, and any lines from the old message that don't pertain to your ongoing discussion.

When you have removed all unwanted lines, type: ZZ to end the editor session. Sendmail will say

(continue)

again,at which point you type a Control-D (hold the "ctrl" key down and type a "d"). Sendmail will ask you if you want to

Cc:

someone else. This is your chance to send a copy to anyone your forgot to name in the "mail" line above, or to send yourself a copy (which you alread have, but ...). So, either type in another address or hit the return again and your mail is on its way.

If the MAILER-DAEMON strikes again, re- proceed to step one above and try, try again.

How to Mail a File

Scenerio: You have a text file, in your computer account (created any way you like) and you wish to send it to someone via electronic mail.

1. Find the filename. Remember, Unix is case-sensitive, so you must know the exact filename (e.g. Fieldnote1 and fieldnote1 are different files as far as Unix is concerned).

2. Start up a sendmail session, as in:

% mail username

Give your message and subject and hit the return key to get a blank line. Hit it again for good measure (if the mailer is going to eat a line it grabs either the first or last line in the file). On your new line, type:

~r exactfilename

(that first character is the tilde ~)

If you have the correct filename, the machine will respond:

"exactfilename" 18/237

meaning it has found the file and "read" it into your outgoing message. Hit the return key once more for good measure and type a Contol-D. Carbon Copy (Cc:) as desired and your done!


(c)Copyright 1985, 1996 by Bruce Jones
Anyone is free to reproduce any of these documents in their entirety or parts thereof providing:
  1. Sections used are reproduced entirely and without alteration
  2. The following page footer is reproduced on each page:
    BJ's UNIX Primer - (c) Bruce Jones - 1985, 1996
  3. Full credit is noted somewhere in the reproduction
Bruce Jones 			Department of Communication
bjones@ucsd.edu			University of California, San Diego
(619) 534-0417/4410		9500 Gilman Drive
FAX (619) 534-7315		La Jolla, Ca. 92093-0503

Comments to:
bjones@ucsd.edu


Return to:
Bruce Jones Homepage
BJ's Unix Primer Index
The CommWeb Homepage

This page last updated on: Feb 3 1997