Tuesday, May 27, 2008

sendmail Mail Administration

The sendmail daemon is a service that runs in the background on your UNIX machine to provide electronic mail services to users on a TCP/IP network. sendmail is what is known as a mail transfer agent (MTA). Although other MTAs are supported by UNIX (e.g., qmail), sendmail is by far the most commonly used one. The sendmail environment is the most complex service available on UNIX. In addition to simply sending messages from one user to another, sendmail determines how to best route the messages across networks to reach a particular destination. Finally, it provides forwarding services so that mail items can be redirected to destinations other than those they were originally sent to. Since sendmail is so complex, we will only address the basics that will allow you to get started as a network administrator for this service. If you want to learn more details, see the “How to Find Out More” section at the end of this chapter.

It is important to understand the distinction between a mail delivery function and a mail reading function. The sendmail daemon only provides the capability to encapsulate (package) a mail message so that it can be sent over a UNIX network. To read a message, a user must have an MUA (mail user agent), or mail reader, installed on the machine receiving the mail. Examples of MUAs are pine, Elm, and mailx. User interaction with sendmail is discussed in Chapter 8.

The sendmail program may already be on your machine. If it is not, you can get it for free. The best source is the official sendmail site at http://www.sendmail.org/. You can read more about sendmail in the Usenet newsgroup comp.mail.sendmail.

Once you have sendmail on your machine, you must configure it for your particular environment to use it effectively. This is done through entries in the sendmail.cf file (sendmail configuration file). This configuration file sets up the options to be used in sending mail and defines the locations of files it uses to do so. It also defines the message transfer agents (or mailers) that sendmail uses to route messages over the network. Lastly, it defines rules for senders and recipients of mail and mailers that are used on your system.

Monitoring sendmail Performance

To provide timely mail service to users on your system, not only must you configure sendmail properly, but you must also tune it and periodically and monitor its performance. The program includes a number of options that help you do this. Here are some of the more important ones that can be used when you start up the sendmail daemon:

Option

Function

–ohhop_count

Specifies the maximum number of hops for a message. sendmail will assume a problem exists and discard messages when this count is exceeded.

–oCckpt_value

Specifies how often sendmail should check the queue to see how many messages are awaiting mailing.

–qtime

Specifies how often outgoing mail is to be batch processed.

–oxload_average

Specifies a limit for the average system load, at which sendmail stops sending outgoing mail.

–oXload_average

Specifies a limit for the average system load on incoming mail, at which sendmail stops receiving mail.

Networked Mail Directories

A configuration you may find useful in a closely coupled environment is to use NFS to share the directory /var/mail between multiple machines. In this way, mail gets stored on only one file system. In the event that your particular machine is down, you can most likely use another machine on your network that has access to the mail directory /var/mail on the server.

First, decide which machine will be the primary machine that will normally have the mail file system mounted, such as company1. Second, move all mail currently found on the secondary machines to the primary machine. Next, remove the directory /var/mail/:saved from all of the secondary machines. (This directory is normally used as a staging area when mail is rewriting mail files.) Then, tell mail where it should forward the mail message if it finds that the /var/mail directory is not mounted properly Do this by adding the following variable to the mail configuration file:

FAILSAFE=company1

Finally, mount the mail directory from the primary machine using NFS. Take caution to NFS-mount the mail spool directory as a hard mount (do not use the soft option). A soft mount may cause corruption of mail. For example, if the spooler is mounted with the soft option, and you are attempting to write to your local mailbox, and sendmail is attempting to deliver mail at the same time, your mail files may become corrupted.

Setting Up SMTP

SMTP (Simple Mail Transfer Protocol) is a protocol specified for hosts connected to the Internet that is used to transmit electronic mail. SMTP is used to transfer mail messages from your machine to another machine across a link created using the TCP/IP network protocol. The sendmail daemon sets up an SMTP service for both the mail client (the user who sends mail) and the mail server (the sendmail process that sends messages over the network). SMTP is the most popular mail protocol daemon for sending mail. To read your mail, you need an additional daemon. One example is the POP3 (Post Office Protocol level 3) protocol daemon. This daemon allows you to receive mail from the network in a format that can be read by a mail reader on your system. One specialized POP3 daemon is called qpopper, used to support mailers such as Eudora. You can obtain this daemon from Eudora at http://www.eudora.com/. Eudora is now a product of Qualcomm, Inc. If you use elm as your mail reader, you do not need to set up a mail reading daemon such as POP3, since elm reads directly from the mail spool directory

Mail Domains

The most commonly used method of addressing remote users on other computers is by specifying the list of machines that the mail message must pass through to reach the user. This is often referred to as a route-based mail system, because you have to specify the route used to get to the user, as well as the user’s address.

Another method of addressing people is to use what is known as domain addressing. This is the primary way in which web browser-based e-mail is sent; for example, sending mail to dhost@domain.com In a domain-based mail system, your machine becomes a member of a domain. Every country has a high-level domain named after the country; high-level domains are also set aside for educational and commercial entities. An example of a domain address is usermachine.company.com, or equivalently, machine.company. com!user. Anyone properly registered can send mail to your machine if they know how to get directly to your machine or know the address of another, smarter host (commonly referred to as the gateway machine) that does have further information on how to get to your machine; this may require the use of other machines on the way This cannot be done unless your machine is registered with the smarter host and you have administered the gateway machine on your system as the smarter host. If you have SMTP configured, your system may be able to directly access other systems in other domains.

Once you have registered your machine within a domain, you must set the domain on your system. This can be done in several ways:

  • If your domain name is the same as the Secure RPC domain name, then both can be set by using the /usr/bin/domainname program, using a line of the form

    domainname .company.com
  • If you have a name server, either on your system or accessible via TCP/IP, the domain name can be set in the name server files, /etc/inet/named.boot or /etc/resolυ.conf, using a line of the form

    domain company.com
  • The domain name can also be overridden within the mail configuration file using a line of the form

    DOMAIN=.company.com

No comments: