DistributedNetworks DistributedNetworks


Unix Network Admin   «Prev  Next»
Lesson 8Running and troubleshooting sendmail
ObjectiveTest a new sendmail configuration file before deploying it.

Running Troubleshooting sendmail

Running sendmail

The sendmail program is usually started at boot time and runs as a daemon process. The command line for starting sendmail is:
/usr/sbin/sendmail -bd -q15m
Here the -bd option means sendmail should run as a daemon, while -q15m means that sendmail will try to deliver email from its queue every 15 minutes. Specifying -q1h means every hour. Other time specifications are possible, and described on the sendmail man page.

Testing sendmail.cf

After installing a new sendmail.cf file, you should test it for problems before deploying it. First, kill the sendmail daemon. Then, use sendmail with the -C argument to use an alternate configuration file:
/usr/sbin/sendmail -bd -q15m -C /testfiles/sendmail.cf

Troubleshooting Tips

The sendmail program reports on its activities in a log file. Which log file sendmail reports to depends on the configuration of the system log, but /var/log/maillog is very common.
More detailed information about what sendmail is doing may be obtained with the -d and -X options. The -X argument has sendmail create a text file that captures all output. For example:
/usr/sbin/sendmail -bd -X/tmp/sendmail.out

This output tells sendmail to capture all sendmail operation in the file /tmp/sendmail.out. The -d option turns out debugging output.
Generally, you will want to use the -d argument with -X. With -d, you can specify a flag to limit output. Each flag has a number and a level. The d0.1 flag, for example, sets flag 0 at level 1, which allows you to search for host names. Generally, you do not need to specify a level higher than 9, because you would get too much information. The higher the flag, the more information you will get. The flag value always is specified first. If you specify -d32, you will get flag 32, not level 32.

Examples and alternatives

The following command allows you to test for flag 32, which gathers all SMTP information:
/usr/sbin/sendmail -bd -d32 -X/tmp/sendmail.out

As you test sendmail, you can use the tail command to read the file /tmp/sendmail.out you specified above. For example, tail -f /tmp/sendmail.out will let you view output to the file as sendmail generates it. Use the -v option to run sendmail in verify mode. This option has sendmail execute without actually sending messages.

Sendmail Configuration - Exercise

Click the Exercise button to test a new sendmail configuration before deploying it.
Sendmail Configuration - Exercise