For the complete documentation index, see llms.txt. This page is also available as Markdown.

Sending email from your FreeBSD server using DMA

DMA, short DragonFly Mail Agent, is the default mail agent since FreeBSD 14.


The new mail agent, DMA (DragonFly Mail Agent), for FreeBSD is much easier to configure than the old sendmail server.

DMA is a small, simple mail transfer agent and is used only to send outgoing emails from the host. It does not listen on port 25 for incoming connections, so it won't be able to receive messages from the outside.

DMA doesn't run any daemon, so there's no service to restart after changing the configuration files.

DMA can be used completely standalone; that is, it can send outgoing emails directly to the receiving email server. It can also be used with a smarthost (also called a relay host), such as an ISP's SMTP server, Sendgrid, Glesys's email service, or similar services.

Standalone

If your FreeBSD machine has a correctly configured hostname, you can start sending outgoing emails directly, without any additional configuration.

However, if you want to send outgoing emails from a different hostname, you set the hostname using the MAILNAME variable in /etc/dma/dma.conf. For example:

Snippet from /etc/dma/dma.conf
MAILNAME example.com

If you want all of your outgoing emails to appear from a single user, you can set this using the MASQUERADE option. For example, to always send as the user info using the current hostname:

Snippet from /etc/dma/dma.conf
MASQUERADE info@

Or, you can set the complete email address, such as:

Snippet from /etc/dma/dma.conf
MASQUERADE info@example.com

Enabling TLS/SSL

If you want to use TLS/SSL for the connections, the following three options are good to enable:

Snippet from /etc/dma/dma.conf
SECURETRANSFER
STARTTLS
OPPORTUNISTIC_TLS

This enables TLS/SSL and STARTTLS, but allows unencrypted connections if the receiving host doesn't support it.

With a smarthost

To use a smarthost (also called a relay host), all you need to do is set the smarthost address and port in /etc/dma/dma.conf, and the username and password in /etc/dma/auth.conf.

The following is a complete example using Glesys's email service as a smarthost, with TLS/SSL enabled, and all outgoing emails being masqueraded as info@example.com.

Please note that you need to create an email account before using Glesys's email service as a smarthost. See Create an email account for more information. The MASQUERADE email address must match your email account's address.

The password and username are set in /etc/dma/auth.conf using the form username|smarthost.example.com:password.

That's all that's required to start sending emails from your FreeBSD server using Glesys as a smarthost.

Testing

You can send an email using the built-in mailx command. Specify the recipient's email address as a command-line argument. After that, mailx starts in interactive mode. You'll first be asked to enter a subject. Press Enter once you have typed your subject line. After that, you'll compose the body of the message. Once the body is complete, make a new line by pressing Enter, type a single dot on the new line, and then press Enter again to send the email. You'll now see the text EOT, meaning End Of Transmission.

Troubleshooting

The log file /var/log/maillog often provides useful hints in case something isn't working.

Last updated

Was this helpful?