-->
Page 173
This hour shows you how to set up your Linux system to handle electronic mail. You'll also explore various programs you can use to read and send mail.
First you'll learn to set up your system to send and receive mail, building on your experience in setting up and connecting with your ISP using PPP.
There's not really much to do to set up your system to send and receive mail, although configuring the main mail daemon, sendmail, is complex enough to be considered a black art, suitable only for UNIX wizards. You shouldn't be intimidated though, because you can use email right after you install Linux and create other users.
I can't discuss all of the details about UNIX mail in this hour, but you should understand how electronic mail works in general. The main programs involved in email are, in technical terms, transport agents and user agents. A transport agent is a program, usually a daemon, which sends mail files from one computer to the next automatically. A user agent is a program, also called a mail reader, which you use to manage messages.
Page 174
After you install Linux, you'll find all of the programs you need to compose, send, and receive mail. The transport agent used in Linux is sendmail, and it is configured and run automatically when you boot the operating system. As far as user agents go, you have your choice, and they are discussed later in the hour.
Because you're connecting to the Internet with a PPP connection, the general approach to handling mail outlined in this hour is to log in and connect, retrieve mail, and then disconnect (or stay connected for a few quick replies). If you've experimented with free email account programs for other operating systems, you know the general approach is to minimize connect time by composing and replying to mail offline, then connecting, sending and retrieving mail, followed by logging off.
If you want the details about Linux mail handling, along with pointers to other sources of information, read Vince Skahan's Mail-HOWTO under the /usr/doc/HOWTO directory.
By now you're probably wondering how to get your email from your ISP. If you recall from the last hour, you should have the IP address or name of your ISP's mail server. To get your mail, you'll need the popclient program, found in the /usr/bin directory. You'll also need to know what Post Office Protocol, or POP, your ISP uses, along with your username and password. Most ISPs support either POP2 or POP3, which are simple protocols for retrieving your messages.
Put all this information together, connect to your ISP, and then grab all your waiting email with one command line:
# /etc/ppp/ppp-on # popclient -3 -u username -p password mailserver.yourisp.com
You can also put this command line into a text file, use chmod +x, and call it as follows:
# domail QUALCOMM Pop server derived from UCB (version 2.1.4-R3) at megan starting. 3 messages in folder reading message 1. reading message 2. reading message 3......
The popclient program is designed to work only one way; it retrieves your mail from your ISP's mail server, then tells your ISP's mail server to delete your mail after it is received. You can also use other options, such as telling your ISP's mail server to keep copies of your mail even after you retrieve, or to put your retrieved mail into an optional directory on your system. By default, your mail will go into a single file with your username under the /var/spool/mail directory. See the popclient manual page for more options.
Page 175
If you'd like to try an another program instead of popclient to retrieve your mail, you may want to try fetchmail. This program offers a few more features, and can run in daemon mode, checking to see if you have mail while you're connected to your ISP. Using fetchmail is easy, for example:
# fetchmail -p POP3 staffnet.com Enter password for bball@staffnet.com: 1 message from bball@staffnet.com. reading message 1 (581 bytes) flushed
fetchmail will prompt for your password (so you can gain access to your ISP's mail server), then retrieves your mail and flushes (or deletes) your mail from your ISP's mail server. fetchmail also has a nifty option, -c, which unlike popclient's -c option, will merely check to see if you have mail waiting, and report the number of messages. See fetchmail's manual page for more information.
Now that you've retrieved your mail, how do you read it, or reply to messages? This is where user agents, or mail-reading programs, come in.
This section introduces you to three basic mail programs you can use under Linux. The explanations start with one of the oldest, the mail program, then follow with two screen-oriented programs, pine and elm.
The mail program, found under the /bin directory, is the simplest mail program you can use, but it is not screen-oriented. mail can send and receive mail, but you're limited to working on a line-by-line basis. This program is handy for quick messages and is easy to use. For example, to create a quick message, call mail with an address on the command line:
# mail bball@staffnet.com Subject: Using the mail Program This is how to use the mail program! Have fun, and enjoy. . EOT
The mail program will respond by asking for a Subject: line. Enter your text, and then press the Enter key. Then, type each line of text, and when you're done, put a period (.) on a line by itself. The mail program will then send the message. Retrieving your messages is easy. After you connect to your ISP, and retrieve your mail using either popclient or fetchmail, you can simply type mail on the command line, for example: