ssmtp - send a message using smtp

When having sendmail disabled:

sendmail_enable="NONE"

ssmtp helps to send email using an SMTP server:

Install ssmtp:

pkg install ssmtp

Configure to use you provider mailgun in this example /usr/local/etc/ssmtp/ssmtp.conf:

root=[email protected]
mailhub=smtp.mailgun.org
AuthUser=[email protected]
AuthPass=yourpassword
UseTLS=Yes
UseSTARTTLS=YES
FromLineOverride=YES

Edit /etc/mail/mailer.conf to use ssmtp:

sendmail        /usr/local/sbin/ssmtp
send-mail       /usr/local/sbin/ssmtp
mailq           /usr/local/sbin/ssmtp
newaliases      /usr/local/sbin/ssmtp
hoststat        /usr/bin/true
purgestat       /usr/bin/true

Now all email sent to root will be sent to [email protected] for example to email the current kernel options:

sysctl kern.conftxt | mail root