-->
Previous Table of Contents Next


Sending a Prepared Message

You may want to use a text editor such as vi to compose a message to be sent by e-mail. If you use a text editor, you have the tools to do things such as format the text and check your spelling. It doesn’t matter what program you use to create the text, as long as you end up with a text or ASCII file.

Suppose that the file you want to send is named report.txt and the recipient’s address is top@kite.fish.com. There are essentially three ways to send the file, as outlined in the following list. In the following examples, the mail command uses the option -s, and the string that serves as the subject heading is surrounded by quotation marks:

  Use a pipe. To send report.txt with the mail command, enter the following:

  cat report.txt | mail -s” Sales Report” top@kite.fish.com

  Redirect input. To send report.txt with the mail command and the -s option, enter the following:

mail -s” Sales Report” top@kite.fish.com < report.txt

  Use ~r to include a file in a message. To use mail to send the file (by using the default Subject prompt), enter these commands:

mail top@kite.fish.com

Subject: Sales Report

~r report.txt

~.

EOT

You see the system prompt after you complete any of these three methods; the result is the same in any case.


NOTE:  In the third example, you use ~r to read, or include, the file report.txt in the e-mail message. This is an example of a tilde command. To use such commands, you precede a command with the tilde character (~) while you’re reading or sending mail. You may find several other tilde commands useful; they’re discussed at appropriate points throughout the chapter.

Sending the Result of a Command or Program by E-Mail

If you run a command or program that produces results to the screen (known as stdout), you can pipe that output to a mail command. Suppose that you have some information in a file called contrib.lst, use the sort command to sort the file, and then send the results to yourself (login name bkorn) and top (whom you met earlier in this chapter). To do all that, enter this command:


sort contrib.lst | mail -s “Sorted Contrib Info” bkorn top@kite.fish.com

Reading Your Mail

Most Linux systems notify you when you log in that you have e-mail. It’s up to you to read and act on it. You can use mail or another e-mail program to read any mail you have. As you read your mail, the e-mail program marks each message as read. Depending on what commands you use and how you quit the e-mail program, the messages you’ve read are kept either in your system mailbox, /var/spool/mail/$LOGNAME, or in your login directory in the file named mbox.

Using mail to Read Mail

To read your mail with mail, enter mail. If your login name is bkorn, you’ll see a display similar to this (what you type is in bold):


mail

mail     Type ? for help.

“/var/spool/mail/bkorn”: 5 messages 2 new 1 unread

     1 sarah Wed Jan  8 09:17  15/363

     2 top@kite.fish.com Thu Jan  9 10:18  26/657   Meeting on Friday

U    3 fred_Fri Jan  10 08:09  32/900   New Orders

> N  4 jones Fri Jan  10 13:22  35/1347  Draft Report

N    5 smith@somewhere.com Sat Jan  11 13:21  76/3103  Excerpt from book

?

Here are some things to note about the display:

  The first line identifies the program and says to type a question mark for help.
  The second line indicates that mail is reading your system mailbox, /var/spool/mail/bkorn, and that you have five messages. Two have arrived since you last checked your mail, one appeared previously but you haven’t yet read it, and two messages have already been read.
  The next five lines give information about your mail. Ignore the first few characters for now. Each line holds a message number, the address of the sender, the date the message was sent, the number of lines and characters in the message, and the subject (if one was given). Consider the following line:

2 top@kite.fish.com  Thu Jan  9 10:18  26/657  Meeting on Friday


This line indicates that message number 2 is from top@kite.fish.com—an address that indicates the message came to your machine from another network (mail from a local user is marked with just the user’s login ID). The message was sent on Thursday, January 9, at 10:18; it consists of 26 lines and 657 characters. The subject is Meeting on Friday.
  A message line starting with N indicates new mail—mail received since you last checked your e-mail. A message line starting with U indicates unread mail. A message line without N or U indicates mail you’ve read and saved in your system mailbox.
  The greater-than character (>) on a message line marks the current message—the message you’ll act on next.
  The question mark (?) on the last line is the command prompt from mail.

Reading the Current Message

The current message is the message marked by the greater-than character (>). To read that message, just press <Return>. When you open it, you see something like the following:


Message 4:

From jones Fri, Jan 10 13:22 EST 1997

Received: by your.system.com

Date: Fri, 10 Jan 1997 13:22:01 -0500

From: Carol Jones <jones>

Return-Path: <jones>

To: aborat, lynn, oackerm, bkorn

Subject: Draft Report

Here is a draft of the report I intend to submit next week.

Please take a look at it and let me know your comments.

Thanks.

----------------Report Starts Here----------------

Opportunities for Expansion

Prepared by Carol Jones

Over the past 6 months, we’ve seen an indication of an increase in the

demand for our services. Current market trends indicate that the demand

will continue for at least 18 months and possibly longer. The manager of

our service staff states “We’re up to our necks in new customers and

:

The message is displayed one screen at a time. Any time you see a colon, you can press <Return> to see the next screen or <q> to quit viewing the message. Press <Return> to see the next screen of the message.

When you see the last screen, you see EOF: (for end of file). Press <q> or <Return> to get back to the ? prompt. Notice that the greater-than character still points to the message you’ve just read. The message that was the current message is still the current message.


Previous Table of Contents Next