A few pieces of software have propelled Linux into the world of mainstream computing. Among them are Apache, BIND, and, of course, Sendmail. This one program manages an estimated 70 percent of all Internet e-mail traffic. With such a broad installed base, Sendmail truly is one of the building blocks of today’s Internet. Let’s look at where to get this popular mail program and how to install it. Then, we’ll discuss the basic configuration files to get it up and running.
Because Sendmail is a widespread SMTP server, it is a common target for hackers. So if you’re installing it for the first time or looking to upgrade, make sure that you’re running the latest version by going directly to www.sendmail.org. As I write this article, the latest version is 8.12.0. An item of note for this version of Sendmail is that it no longer runs as set-user-id. This is good for the security-conscious out there, as it lowers the possibilities of root exploits.
After downloading the source package sendmail.8.12.0.tar.gz, extract it to its own directory with the command tar xvfz sendmail.8.12.0.tar.gz. I’m sure I don’t need to remind you to read all of the README and INSTALL files contained within the package—particularly /sendmail/README and /cf/README.
You can begin the installation by executing sh Build from within the /sendmail subdirectory. This is a script provided with the distribution and will take the place of using configure and make.
Next, change location into the cf/cf/ directory and copy generic-linux.mc to sendmail.mc with the command cp generic-linux.mc sendmail.mc. At this point, sendmail.mc is a generic template and needs to be run using the m4 command in order to produce a .cf file; for example:
m4 /etc/mail/sendmail.mc > /etc/sendmail.cf
Sendmail uses the m4 macro processor to compile the configuration files. You may want to change the initial values based on instructions from /cf/README. For instance, this is what my sendmail.mc file looked like before I ran the install script:
VERSIONID(`$Id: generic-linux.mc,v 8.1 1999/09/24 22:48:05 gshapiro Exp $')
Lines that begin with FEATURE are new to the file. Keep in mind that they must be located after the DOMAIN directive and before the MAILER directives. A comprehensive list of options is provided in the /cf/README file. Be sure to browse through it prior to installation; it could save you a lot of trouble later on.
After tailoring the sendmail.mc to your specific needs, simply run sh Build sendmail.cf from the current directory. This will automatically process the configuration file through m4. If you are currently running a version of Sendmail, be sure to back up your current /etc/mail/sendmail.cf and the sendmail binary (which is usually found in /usr/sbin or/usr/lib). Then, install sendmail.cf as /etc/mail/sendmail.cf and submit.cf as /etc/mail/submit.cf. You can do this from /cf/cf by running sh Build install-cf.
At this point, it is recommended that you read sendmail/SECURITY, if you have not already done so. This is important because you have to create a new user and group named smmsp. Starting with 8.12.0, the default installation involves this Sendmail user and a new group (25 being the recommended gid—group ID) to get around the issue of writing to the queue directory. Other issues, such as binding to port 25 and reading .forward files, can be provided for by running Sendmail as root.
The problem comes into play when mail is sent from the command line. Instead of root being the only one able to write to the queue directory, Sendmail now runs as a set-group-ID. This allows write access to the directory. After creating the new user and group, change directories back into /sendmail and install the sendmail binary by running sh Build install. You should have backed up your binary in a previous step but also be sure to stop the Sendmail daemon if you have not already done so.
Sendmail also comes with utilities that need to be compiled and installed. These include makemap, mailstats, and smrsh. The directions from the INSTALL file say to go into each directory, read the README, and install each one separately. Do read the help files but note that you can actually install the utilities together by running sh Build install from the sendmail-8.12.0 directory created when you extracted the package originally. If you’re running a previous version of Sendmail, now would be a good time to remake the database maps in /etc/mail. To accomplish this, back up your previous .db files, remove the old ones, and run make from that directory.
With Sendmail 8.9, the new configuration directory /etc/mail made an appearance. All files will use this directory by default, including the main configuration file sendmail.cf. Other Sendmail configuration files are contained in the subdirectory /cf, with the suffix .mc. As you now know, they must be run through m4 to produce a .cf file. Some other common files that you will undoubtedly come across are /etc/mail/aliases and /etc/mail/local-host-names.
The aliases file provides for a way to have multiple e-mail addresses point to the same user or multiple users to have one e-mail box. One example of this would be to create an e-mail user firstname.lastname@example.org that is a logical address for an entire department. Simply add an entry in the /etc/mail/aliases file that points email@example.com to multiple recipients:
# Marketing Department
marketing: firstname.lastname@example.org, email@example.com, firstname.lastname@example.org
This is an easy way to make sure that everyone gets a copy of inbound e-mails, and it’s also a single point of administration for personnel changes. Remember to run the program newaliases after making changes to this file in order to update the system.
The local-host-names file provides alternate names for the local host. This is important, as Sendmail will verify inbound e-mail and may not accept it for hosts that are not listed here. If you are running a mail server for multiple domains, this can be a key step for ensuring that no mail is lost.
# local-host-names – include all aliases for your machine here
Sendmail has attempted to make its configuration simpler by combining files and making one central directory, /etc/mail. However, this does not eliminate some of the inherent difficulty in dealing with mail transport and delivery. Be sure to read all of the documentation included with the package, as well as all the helpful information on www.sendmail.org.
Sendmail is one of the leading mail programs in the world and for good reason. It is in a constant state of development and receives excellent feedback from its large installed base. Sendmail is also one of a handful of enterprise-level programs that is bolstering Linux to become a viable contender in the Internet industry. With so many individuals and organizations running Sendmail, you can be sure of finding assistance with virtually any facet of the program. Now you should have a good idea of where to start in getting Sendmail installed and up and running on your Linux system.
Do you have tips for working with Sendmail?
We look forward to getting your input and hearing about your experiences regarding this topic. Join the discussion below or send the editor an e-mail.