This entry is intended to replace the default FreeBSD MTA agent with one that is easier to manage. Because of its simplicity we are going to use SSMTP as it takes very few configuration lines.

Installation

Install the binary:

pkg install -y ssmtp

Configuration

Disable Sendmail

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

Configure SSMTP

In this section you have to change the information between the tags <> for the corresponding information in each case.

sed -ip "s/postmaster/<admin@email.address>/" /usr/local/etc/ssmtp/ssmtp.conf
sed -ip "s/mailhub=mail$/mailhub=<email.server>/" /usr/local/etc/ssmtp/ssmtp.conf
echo "root:root@$HOSTNAME" >> /usr/local/etc/ssmtp/revaliases
sed -ip "s/\/usr\/libexec\/sendmail\/sendmail/\/usr\/local\/sbin\/ssmtp/" /etc/mail/mailer.conf
pw useradd ssmtp -g nogroup -h - -s /sbin/nologin -d /nonexistent -c "sSMTP pseudo-user"
chown -R ssmtp:wheel /usr/local/etc/ssmtp
chown ssmtp:nogroup /usr/local/sbin/ssmtp
chmod 4555 /usr/local/sbin/ssmtp

Tests

At this point we can perform some simple tests to verify that the new MTA of this system is functional.

echo "This is a test" | mail -s "Test" address@e.mail