Herr Bischoff


FreeBSD 13: Simple Outgoing Email with dma

Having a server send emails is a useful and important functionality. Luckily, the DragonFly Mail Agent is part of the FreeBSD base system. Here’s how to set it up to send emails through an external mail server.

First, disable sendmail completely:

service sendmail onestop
sysrc sendmail_enable="NONE"

Replace and/or create a couple of files with the following content:

# /etc/dma/dma.conf

SMARTHOST mail.example.org
PORT 587
AUTHPATH /etc/dma/auth.conf
SECURETRANSFER
STARTTLS
# /etc/dma/auth.conf

user@example.com|mail.example.org:mysupersecretpassword
# /etc/mail/mailer.conf

sendmail      /usr/libexec/dma
send-mail     /usr/libexec/dma
mailq         /usr/libexec/dma
newaliases    /usr/libexec/dma
rmail         /usr/libexec/dma
hoststat        /usr/bin/true
purgestat       /usr/bin/true

Update the aliases file:

sed -i '' 's/# root:.*me@my.domain/root: user@example.com/' /etc/mail/aliases
newaliases

Test the setup:

mail -v -s testing01 user@example.com < /etc/rc.conf