Networking / Beginners


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.

An open relay is a mail server that's configured to allow anyone to use it as a relay for sending mail. In short, an open relay sends mail when neither the sender nor the recipient is a local user. Spammers love open relays because they can use them to obscure the true origin of their junk e-mail. As a result, open relays are a major contributor to the Internet spam problem.

Fortunately, the default configuration for the current version of Sendmail (8.14) is to not allow open relaying. As a result, you have to go out of your way to become an open relay with Sendmail. In fact, you'll have to look up the lines you'd need to add to to enable open relaying.

If you do need to allow relaying for specific hosts, create a file named relay-domains in /etc/mail. Then, add a line for each domain you want to allow relaying for. This line should contain nothing but the domain name. Then restart Sendmail.

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 ryan. 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: 	ryan 	harris 	harris

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

[Previous] [Contents] [Next]