Выбрать главу

The MDA uses the POP3 or IMAP protocols for this process. In a manner similar to a post office box at the post office, POP3 and IMAP implement a "store and forward" process that alleviates the need to maintain a local mail server if all you want to do is read your mail. For example, dialup Internet users can intermittently connect to their ISPs' mail servers to retrieve mail by using Fetchmail — the MDA provided by Fedora (see the section "Using Fetchmail to Retrieve Mail," later in this chapter).

The Mail User Agent

The mail user agent, or MUA, is another necessary part of the email system. The MUA is a mail client, or mail reader, that enables the user to read and compose email and provides the user interface. (It is the email application itself that most users are familiar with as "email.") Some popular UNIX command-line MUAs are elm, pine, and mutt. Fedora also provides modern GUI MUAs: Evolution, Thunderbird, Mozilla Mail, Balsa, Sylpheed, and KMail. For comparison, common non-UNIX MUAs are Microsoft Outlook, Outlook Express, Pegasus, and Eudora.

The Microsoft Windows and Macintosh MUAs often include some MTA functionality; UNIX does not. For example, Microsoft Outlook can connect to your Internet provider's mail server to send messages. On the other hand, UNIX MUAs generally rely on an external MTA such as Sendmail. This might seem like a needlessly complicated way to do things, and it is if used to connect a single user to her ISP. For any other situation, however, using an external MTA provides you much greater flexibility because you can use any number of external programs to handle and process your email functions and customize the service. Having the process handled by different applications gives you great control over how you provide email service to users on your network, as well as to individual and SOHO (small office/home office) users.

For example, you could

► Use Evolution to read and compose mail.

► Use Sendmail to send your mail.

► Use xbiff to notify you when you have new mail.

► Use Fetchmail to retrieve your mail from a remote mail server.

► Use Procmail to automatically sort your incoming mail based on sender, subject, or many other variables.

► Use Spamassassin to eliminate the unwanted messages before you read them.

Basic Sendmail Configuration and Operation

Because Sendmail is the Fedora default client (and the mostly widely used client), the following sections provide a brief explanation and examples for configuring and operating your email system. As mentioned earlier, however, Sendmail is an extremely complex program with a very convoluted configuration. As such, this chapter covers only some of the basics. For more information on Sendmail, as well as other MTAs, see the "Reference" section at the end of this chapter.

Sendmail configuration is handled by files in the /etc/mail directory, with much of the configuration being handled by the file sendmail.cf. The actual syntax of the configuration file, sendmail.cf, is cryptic (see the following example). In an attempt to make it easier to configure Sendmail, the sendmail.mc file was created. The following example belies that goal, however. The sendmail.mc file must be processed with the m4 macro processor to create the sendmail.cf file; the needs of that processor account for the unusual syntax of the file. You will learn how to use it later, and we see a Perl script that automates and simplifies the entire process. First, let's examine some basic configuration you might want to do with Sendmail.

NOTE

sendmail.cf has some strange syntax because of the requirements of the m4 macro processor. You do not need to understand the details of m4 here, but note the quoting system. The starting quote is a backtick (`), and the ending quote is simply a single quote ('). Also, the dnl sequence means to "delete to new line" and causes anything from the sequence up to and including the newline character to be deleted in the output.

Here's a look at an excerpt from the sendmail.cf file:

CP.

# "Smart" relay host (may be null)

DS

# operators that cannot be in local usernames (i.e., network indicators)

CO @ % !

# a class with just dot (for identifying canonical names)

C..

# a class with just a left bracket (for identifying domain literals) C[[

# access_db acceptance class

C{Accept}OK RELAY

C{ResOk}OKR

# Hosts for which relaying is permitted ($=R)

FR-o /etc/mail/relay-domains

And here's a quote from the sendmail.mc file for comparison:

dnl define(`SMART_HOST',`smtp.your.provider')

define(`confDEF_USER_ID',``8:12'')dnl

undefine(`UUCP_RELAY')dnl

undefine(`BITNET_RELAY')dnl

dnl define(`confAUTO_REBUILD')dnl

define(`confTO_CONNECT', 4m')dnl

define(`confTRY_NULL_MX_LIST',true)dnl

You can see why the file is described as cryptic.

Complicated email server setup is beyond the scope of this book; for more information on this topic, we suggest Sendmail, 3rd Edition by Costales and Allman, a 1,200-page comprehensive tome on Sendmail configuration. However, the following five sections address some commonly used advanced options.

Configuring Masquerading

Sometimes you might want to have Sendmail masquerade as a host other than the actual hostname of your system. Such a situation could occur if you have a dialup connection to the Internet and your ISP handles all your mail for you. In this case, you want Sendmail to masquerade as the domain name of your ISP. For example:

MASQUERADE_AS(`samplenet.org')dnl

Using Smart Hosts

If you do not have a full-time connection to the Internet, you probably want to have Sendmail send your messages to your ISP's mail server and let it handle delivery for you. Without a full-time Internet connection, you could find it difficult to deliver messages to some locations (such as some underdeveloped areas of the world where email services are unreliable and sporadic). In those situations, you can configure Sendmail to function as a smart host by passing email on to another sender rather than attempting to deliver the email directly. You can use a line such as the following in the sendmail.mc file to enable a smart host:

define(`SMART_HOST', `smtp.samplenet.org')

This line causes Sendmail to pass any mail it receives to the server smtp.samplenet.org rather than attempt to deliver it directly. Smart hosting will not work for you if your ISP, like many others, blocks any mail relaying. Some ISPs block relaying because it is frequently used to disseminate spam.

Setting Message Delivery Intervals

As mentioned earlier, Sendmail typically attempts to deliver messages as soon as it receives them, and again at regular intervals after that. If you have only periodic connections to the Internet, as with a dialup connection, you likely would prefer that Sendmail hold all messages in the queue and attempt to deliver them at specific time intervals or at your prompt. You can configure Sendmail to do so by adding the following line to sendmail.mc: