How to Enable Sending Email From Your FreeBSD Machine Using Dragonfly Mail Agent (DMA)
Published: Dec 22, 2025
After you’ve setup your FreeBSD box, having the box email you for all sorts of reports, cron updates etc is really useful. You don’t have to login to the machine to see them, you can get them in your email. With DragonFly Mail Agent, the setting of such an email system is quick and easy. Here’s the intructions:
Prerequisites
- Replace [email protected] with your own email address. Make sure you have two factor authentication on and then you can setup an app password.
- Replace “replace-with-your-app-password” with your gmail app password.
- The following using gmail as your SMTP provider.
- Assumes you’re installing this as root.
Part one - setup DMA
Setup of DMA for FreeBSD 14.x
Install DMA
pkg install dma
Backup original config
cp /usr/local/etc/dma/dma.conf /usr/local/etc/dma/dma.conf.bak
Configure DMA
cat > /usr/local/etc/dma/dma.conf << 'EOF'
SMARTHOST smtp.gmail.com
PORT 587
AUTHPATH /usr/local/etc/dma/auth.conf
SECURETRANSFER
STARTTLS
MASQUERADE [email protected]
EOF
Set up authentication
cat > /usr/local/etc/dma/auth.conf << 'EOF'
[email protected]|smtp.gmail.com:replace-with-your-app-password
EOF
Secure auth file
chmod 640 /usr/local/etc/dma/auth.conf
chown root:mail /usr/local/etc/dma/auth.conf
Enable DMA in rc.conf
sysrc sendmail_enable="NO"
sysrc sendmail_submit_enable="NO"
sysrc sendmail_outbound_enable="NO"
sysrc sendmail_msp_queue_enable="NO"
sysrc dma_enable="YES"
Set up mailwrapper
cat > /etc/mail/mailer.conf << 'EOF'
sendmail /usr/local/libexec/dma
mailq /usr/local/libexec/dma
newaliases /usr/local/libexec/dma
EOF
Quick Test
echo "Test email" | mail -s "Test from FreeBSD" [email protected]
Monitor logs
tail -f /var/log/maillog
Setup of DMA for FreeBSD 15.x
Notice the path for dma is different, its simpler in 15.x.
pkg install dma
cp /etc/dma/dma.conf /etc/dma/dma.conf.bak
cat > /etc/dma/dma.conf << 'EOF'
SMARTHOST smtp.gmail.com
PORT 587
AUTHPATH /etc/dma/auth.conf
SECURETRANSFER
STARTTLS
MASQUERADE [email protected]
EOF
cat > /etc/dma/auth.conf << 'EOF'
[email protected]|smtp.gmail.com:replace-with-your-app-password
EOF
chmod 640 /etc/dma/auth.conf
chown root:mail /etc/dma/auth.conf
sysrc sendmail_enable="NO"
sysrc sendmail_submit_enable="NO"
sysrc sendmail_outbound_enable="NO"
sysrc sendmail_msp_queue_enable="NO"
sysrc dma_enable="YES"
cat > /etc/mail/mailer.conf << 'EOF'
sendmail /usr/local/libexec/dma
mailq /usr/local/libexec/dma
newaliases /usr/local/libexec/dma
EOF
echo "Test email" | mail -s "Test from FreeBSD" [email protected]
tail -f /var/log/maillog
Part two - make cron send emails to you
# Create /etc/mail/aliases or add root alias
echo "root: [email protected]" >> /etc/mail/aliases
# Or if you want all mail to go to your Gmail
cat > /etc/mail/aliases << 'EOF'
# Send all system mail to Gmail
root: [email protected]
EOF
# Then rebuild aliases
newaliases
🔵