About FreeBSD

Replace Sendmail with Postfix

Postfix has been used on my mail servers for a number of years. My other servers only need minimal email to send out periodic reports, so Sendmail from the base system is adequate, easily started from /etc/rc.conf and works out of the box (until recently).

After updating FreeBSD to 10.1-RELEASE-p12 a couple of days ago, to address a security advisory relating to OpenSSL, Sendmail now refuses to work. Long story short, I decided to take this opportunity to replace Sendmail with a submit-only PostFix installation.


In the end, we did manage to get Sendmail working again, with a little help from the friendly people at FreeBSD forums.

The issue with Sendmail has been fixed in 10.1-RELEASE-p14.

Installing PostFix

PostFix can be installed as a package by using:

# pkg install postfix

At the end of the installation, the installer will ask if you want to replace Sendmail with PostFix. If you answer yes, then /etc/mail/mailer.conf is overwritten with:

sendmail        /usr/local/sbin/sendmail
send-mail       /usr/local/sbin/sendmail
mailq           /usr/local/sbin/sendmail
newaliases      /usr/local/sbin/sendmail

Configuration Files

PostFix has two main configuration files:

/usr/local/etc/postfix/main.cf
/usr/local/etc/postfix/master.cf

In the case of a simple submit-only Sendmail replacement, only the main.cf file needs to be customised. The configuration parameters that main.cf controls have sensible default values which can keep the configuration file quite short. A reasonable configuration for main.cf might look like:

myorigin = $mydomain
relayhost = $mydomain
inet_interfaces = loopback-only
mydestination =
inet_protocols = ipv4
smtp_tls_security_level = may
smtp_tls_loglevel = 1

Disable Sendmail / Enable PostFix

In /etc/rc.conf:

sendmail_enable="NONE"
postfix_enable="YES"

Certain periodic operations are unnecessary if Sendmail is disabled, so create (or update) /etc/periodic.conf with:

daily_clean_hoststat_enable="NO"
daily_status_mail_rejects_enable="NO"
daily_status_include_submit_mailq="NO"
daily_submit_queuerun="NO"

Reboot the server. Alternatively, stop the Sendmail service and start the PostFix service manually using:

# service sendmail stop
# service postfix start

References