Configuration of Sendmail

The overall configuration of sendmail is beyond the scope of this book and the LPI 102 test. We will instead focus on email address aliasing and mail forwarding, in addition to monitoring logfiles and basic troubleshooting.

Sendmail is a monolithic tool, with a single binary handling the sending and receiving of Internet email. For the purposes of this chapter, we will assume Simple Mail Transport Protocol (SMTP) email, but sendmail supports many other types of mail relaying.

By default, sendmail will listen for an incoming SMTP connection (on TCP port 25). When a connection is received, sendmail starts the SMTP conversation and accepts the email. It checks addresses and domains for validity, honors aliasing and mail forwards, and then hands the mail off to a local delivery agent for local processing. Sendmail logs all activity through the syslog service, which is normally configured to store mail-related logs in the file /var/log/maillog. Here is an example of verifying a sendmail instance and sending a test mail.

# netstat -anpl --tcp | grep sendmail
tcp 0 0* LISTEN \
                     1847/sendmail: accepting connections
# ls -l /var/spool/mail/adamh
-rw-rw---- 1 adamh mail 0 2009-04-24 01:23 /var/spool/mail/adamh
# echo "This is a test email" | mail adamh
# ls -l /var/spool/mail/adamh
-rw-rw---- 1 adamh mail 689 2010-02-07 13:21 /var/spool/mail/adamh
# tail /var/log/maillog Feb 7 13:22:42 server sendmail[5387]: o17JMgbM005387: from=root, \ size=32, ...

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.