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.

Fix:

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/freebsd.mc (or your custom mc-file, if you use one):

define(`confDONT_PROBE_INTERFACES',`true')

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.

Verification:

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

More:

For the sake of completeness:

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

sendmail_enable="NO"

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

sendmail_enable="NO" 
sendmail_submit_enable="NO" 
sendmail_outbound_enable="NO" 
sendmail_msp_queue_enable="NO"

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.



Facebooktwittergoogle_plusredditpinterestlinkedinmail

1 comment

  • MarlaX

    I must say you have high quality posts here.
    Your content should go viral. You need initial boost only.
    How to get massive traffic? Search for; Murgrabia’s tools go viral

Leave a Reply

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