Unixery & daemon worship 🔥

It's a Unix system! I know this!

Make sendmail listen on the loopback interface only

It is almost always necessary to run the sendmail daemon, even on systems that don’t act as public SMTP servers. Without sendmail, output from cron and at jobs won’t be delivered. However, unnecessarily exposing your SMTP ports to the Internet or even to a large LAN is poor security practice. This article will explain how to configure sendmail to listen only on the local loopback interface ( in Slackware.

Required Packages

You must have the sendmail-cf package installed, which in turn requires the m4 package. These packages are available as part of the official Slackware distribution. Also install procmail for local mail delivery and mutt for reading local mail.

Edit the Configuration File

Change into the directory /usr/share/sendmail/cf/cf. This directory is installed by the sendmail-cf package and contains a wide variety of sample sendmail configuration files. The default configuration on Slackware is the sendmail-slackware.mc file.

cd /usr/share/sendmail/cf/cf
cp sendmail-slackware.mc sendmail-slackware-localhost.mc

Edit the new file, and make the following additions. Along with the other FEATURE options, add this line:

dnl# Disable MSA on Port 587

Right before the MAILER lines, add this line:

dnl# Only listen on localhost

Install the Configuration File

m4 sendmail-slackware-localhost.mc > /etc/mail/sendmail.cf

Warning: If you had previously hard-coded any configuration options in sendmail.cf, they will be overwritten. It is recommended (and generally easier) to make changes only to sendmail-slackware.mc and then rebuild sendmail.cf with the command above. Restart Sendmail

/etc/rc.d/rc.sendmail restart

Sending mails

To send mails to other servers in the internet make sure you have a PTR Resource Record (reverse DNS) for your mail server. Otherwise spam filters won’t accept mail from your server. The PTR Resource Record can be set for one domain name only. Check the record with:

dig -x

Also make sure you have the correct host names in /etc/hosts:	 example.com

And in /etc/HOSTNAME (do not add www in front!):


Also note that Slackware has some flaw while setting the hostname in the init script. It uses this command:

/bin/hostname $(cat /etc/HOSTNAME | cut -f1 -d .)

This only sets the string before the first “.” as hostname. Therefore sending mails will not work. Go ahead and change the command to:

/bin/hostname -F /etc/HOSTNAME

You can check sendmail’s hostnames with

sendmail -d0.1 -bv root

You can also check the hostname in the response of the SMTP server:

telnet localhost 25
 -> ehlo client