-->
Previous | Table of Contents | Next |
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 doesnt 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 recipients address is [email protected]. 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:
cat report.txt | mail -s Sales Report [email protected]
mail -s Sales Report [email protected] < report.txt
mail [email protected] 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 youre reading or sending mail. You may find several other tilde commands useful; theyre discussed at appropriate points throughout the chapter.
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 [email protected]
Most Linux systems notify you when you log in that you have e-mail. Its 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 youve read are kept either in your system mailbox, /var/spool/mail/$LOGNAME, or in your login directory in the file named mbox.
To read your mail with mail, enter mail. If your login name is bkorn, youll 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 [email protected] 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 [email protected] Sat Jan 11 13:21 76/3103 Excerpt from book ?
Here are some things to note about the display:
2 [email protected] Thu Jan 9 10:18 26/657 Meeting on Friday
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, weve 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 Were 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 youve just read. The message that was the current message is still the current message.
Previous | Table of Contents | Next |