Configure Sendmail on FreeBSD to only accept local mail for hostnames in /etc/mail/local-host-names

FreeBSD ships with Sendmail (*shudder*). Most people completely disable or replace it with something other.

I just want to have a local mailer daemon for command-line mail which only accepts mail for “localhost” and nothing else.

The problem is that in the default configuration Sendmail probes all available network interfaces and thinks it is responsible for any hostname and IP addresses who are configured on them. This may not be the case.


On FreeBSD one can create a file named /etc/mail/local-host-names. This is where the desired host names go (line-by-line) where Sendmail is responsible for. But without disabling the interface probing, those hostnames will just get added additionally. We need to disable the probing by adding the following line to /etc/mail/ (or your custom mc-file, if you use one):


Now, use the following line to build the config and restart Sendmail:

make all install restart

Thats it. Sendmail should now only process mail for the hostnames listed in /etc/mail/local-host-names.


You can verify Sendmails authoritative hostnames by running sendmail -bt and typing $=w at the prompt (exit with Ctrl+D).


For the sake of completeness:

Disable Sendmails incoming mail-service (listening on external interfaces)  (/etc/rc.conf):


Completely disable Sendmail (/etc/rc.conf):


Be aware that completely disabling Sendmail without installing an alternate MTA is not optimal as for example mails from periodic(8) won’t come through anymore.


Leave a Reply

Your email address will not be published. Required fields are marked *