Network Administration: Configuring Sendmail - dummies

Network Administration: Configuring Sendmail

Sendmail is probably one of the most difficult programs to configure that you’ll ever encounter. In fact, the basic configuration file,, is well over a thousand lines long. You don’t want to mess with this file if you can possibly avoid it.

Fortunately, you don’t have to. The configuration file is generated automatically from a much shorter file called This file contains special macros that are processed by a program called m4. The m4 program reads the macros in the file and expands them to create the actual file.

Even so, the file is a few hundred lines long. Configuring Sendmail isn’t for the faint of heart.

You can find the and files in the /etc/mail directory. Before you edit these files, you should make backup copies of the current files. That way, if you mess up your mail configuration, you can quickly return to a working configuration by reinstating your backup copies.

After you’ve made backup copies, you can safely edit When you’re finished, you can regenerate the file by entering these commands:

cd /etc/mail
m4 >
service sendmail restart

The first command changes the current working directory to /etc/mail. Then, the second command compiles the command into the command. Finally, the third command restarts the Sendmail service so that the changes will take effect.

You need to be aware of two strange conventions used in the file:

  • Unlike most configuration files, comments don’t begin with a hash mark (#). Instead, they begin with the letters dnl.

  • Strings are quoted in an unusual way. Instead of regular quotation marks or apostrophes, strings must begin with a backquote (`), which is located to the left of the numeral 1 on the keyboard and ends with an apostrophe (‘), located to the right of the semicolon. So a properly quoted string looks like this:


The following sections describe the common configuration changes that you may need to make to

Enabling connections

The default configuration allows connections only from localhost. If you want Sendmail to work as a server for other computers on your network, look for the following line in the file:

DAEMON_OPTIONS(`Port-smtp,Addr=, Name=MTA’)dnl

Add dnl # to the beginning of this line to make it a comment.

Enabling masquerading

Masquerading allows all the mail being sent from your domain to appear as if it came from the domain (for example, rather than from the individual hosts (like To enable masquerading, add lines similar to these:


Setting up aliases

An alias — also known as a virtual user — is an incoming e-mail address that is automatically routed to local users. For example, you may want to create a generic account such as and have all mail sent to that account delivered to a user named willie. To do that, you edit the file /etc/mail/virtusers. This file starts out empty. To create a virtual user, just list the incoming e-mail address followed by the actual recipient.

For example, here’s a virtusers file that defines several aliases:      willie        robert  robert

After you make your changes, you should restart the Sendmail service.