-->
Previous | Table of Contents | Next |
Receiving Mail
Linux informs you of incoming mail when you login the system. Youll see a message like:
You have mail.
Unless you read your mail at this point, this message will reappear periodically, as the shell is automatically set up to remind you of unread mail.
To view this mail, type:
gilbert:/$ mail
Youll see something like whats shown in Figure 9.1.
Figure 9.1 Incoming mail.
The shell responds with a list of your mail messages, listed in the order they were received by your system, newest mail first. The first field lists the sender of the message, the second through fifth fields denote the time and date the message was received, the sixth field records the number of lines in the message and the size of the message (in bytes), and the final field indicates the subject of the message.
Press Enter to read the first message on the list. If its a long message, the entire message will scroll by. If you want to stop scrolling the message, type Ctrl-S; to start it again, type Ctrl-Q.
There are two types of messages waiting for us: messages from root and messages from [email protected]. If youre connected to the Internet and have your own network with other users, your electronic mail can come from two sources: your own system and other systems. Mail from other systems, sent on the Internet or the Usenet, has its own unique addressing scheme (more on that in the next section). Mail from your own system uses the same login names as described in Chapter 1; these names are contained in the /etc/passwd file.
The newer addressing scheme, and one that is growing in popularity (mainly because of the growing popularity of the Internet), is called domain addressing. Structured as the exact opposite of a bang path, a domain address couples the name of the user with an address. This scheme grew out of the need for international standardization of electronic-mail addresses and provides a hierarchical structure to addressing. Essentially, the world is split into country domains, which are divided into educational domains (indicated by the suffix .edu in the address) and commercial domains (indicated by the suffix .com in the address). There are hundreds and hundreds of commercial and educational domains, and the number is growing every day.
Reading a domain address is quite simple. In the address of:
reichard refers to the user, while mr.net refers to the domain. The user and domain names are separated by the at (c) symbol. As a user, you dont need to know the specific path a message must take, nor do you need to know the name of a gateway. With a domain address, sending a message is simple:
gilbert:/$ mail [email protected]
The idea of the Internet is fairly amorphous and abstract. The Internet is technically a collection of many networks that somehow manage to talk to each other. As a user, all you need to know is a recipients electronic-mail address; the system administrator handles the basic details of linking a system to the Internet.
If youre on the Internet, you can also receive electronic-mail from afar. To find your machine address, type uname -n at the prompt:
gilbert:/$ uname -n gilbert
where gilbert is the name of your UNIX system, also called the hostname. To list all the systems you can directly communicate with, type uname:
gilbert:/$ uname othersystem1 othersystem2 othersystem3
where othersystem refers to the other systems.
The uname command doesnt support this option on all systems. If this is the case, you can look in the file /etc/hosts covered earlier in this chapter, to get a good idea of what other systems your computer networks with.
In a large regional or nationwide network, the list of other systems can be quite large. If you want to find a specific system and you dont want to wade through a huge list of names, use uname in conjunction with grep:
$ uname | grep othersystem121 othersystem121
If the name of the other system is returned, you can send electronic mail to someone with an account on that system. In addition, you can send messages to people on the Internet if you are connected to the Internet, provided you know the exact address of the recipient.
Lets look at the first message from root, shown in Figure 9.2.
Figure 9.2 An incoming electronic-mail message.
At the beginning of an e-mail message is a header. With the Internet, mail may go between one or more systems on its way to you. You cant count on a direct link between systems, and because of these uncontrollable paths it may take some time for a message to reach the recipient; delivery times of 15 hours to 24 hours are not uncommon, but neither are delivery times of 10 seconds.
Creating Mail
Its very easy to create mail. (Too easy, some would say, as they survey mailboxes full of irrelevant mail messages.) To create a short message at the keyboard, simple combine mail with the name of the recipient, followed by a period on its own line. The resulting mail is shown in Figure 9.3.
Figure 9.3 Incoming mail.
As always, end input from the keyboard by typing Ctrl-D. Some e-mail programs also accept a single period on its own line to terminate the message, instead of Ctrl-D. The procedure would be the same if you were sending a message to a user on a remote machine:
gilbert:/$ mail [email protected]
You can send the same message to multiple users with the -t option:
gilbert:/$ mail -t [email protected] [email protected] This, too, is a test. .
The resulting message will contain multiple To: fields in the header.
Sending an existing file as the text of an electronic-mail message is almost as simple. After creating an ASCII file using vi or emacs, save the file and then redirect it as input on the command line:
gilbert:/$ mail [email protected] < note
Previous | Table of Contents | Next |