Jump to content

# dma

From ArchWiki

Related articles

- Mail server

dma (Dragonfly Mail Agent) is a tiny Mail Transport Agent (MTA). It is able to accept mails and deliver it to local or remote destinations; however, if you want to send and receive mails with your domain name, then you will need a full-featured mail server.

## Installation

Install the dma package.

## Configuration

dma has two main configuration files: `/etc/dma/dma.conf` contains main setup directives and `/etc/dma/auth.conf` is necessary for authentication on SMTP servers. dma provides sane defaults so you may be able to use it without special configuration for local mail delivery.

### SMTP transport

If you want to route mail through external SMTP server you must set `SMARTHOST` address (also known as relay host) in `/etc/dma/dma.conf`:

    /etc/dma/dma.conf

    SMARTHOST smtp-host

Also do not forget to set authentication credentials in `/etc/dma/auth.conf` in the following format:

    /etc/dma/auth.conf

    user|smarthost.example.com:password

To have dma actually use the credentials file, set `AUTHPATH`:

    /etc/dma/dma.conf

    AUTHPATH /etc/dma/auth.conf

To change default port set `PORT` directive (`25` is default):

    /etc/dma/dma.conf

    # accept mail from external MTAs (STARTTLS is also an option)
    PORT 25

    # accept mail from MUAs with TLS
    PORT 465

    # accept mail from MUAs (STARTTLS is also an option)
    PORT 587

### Encryption

`SECURETRANSFER` directive enables encryption during mail transfers. Depending on your needs uncomment `STARTTLS` to enable STARTTLS support and activate `OPPORTUNISTIC_TLS` to permit unencrypted fallback in case of error.

For whatever reason you may want to perform plain text SMTP authentication. In such case uncomment `SECURE` directive and change it to `INSECURE` explicitly.

### Masquerading

If you want to substitute original From: field in envelope you can use `MASQUERADE` feature:

    /etc/dma/dma.conf

    # send mails as user foo (hostname will be derived with gethostbyname() or set to MAILNAME directive)
    MASQUERADE foo@

    # send mails from host bar (username will be substituted)
    MASQUERADE bar

    # send mail as user foo from host bar
    MASQUERADE foo@bar

### Testing

To send test mail execute the following from command line:

    $ mail -s "Just a dma test" foo@bar.example.com
    This is just a small test message
    <Ctrl+D>

Run `journalctl -r` as root to see if all went good. Also you can check dma queue with:

    $ dma -bp

`/var/spool/dma` directory also holds undelivered/unprocessed mails.

## Examples

### Send mails through Google's SMTP servers

#### Prerequisites

If you use 2-Step Verification (also known as two-factor authentication) procedure then you should create so-called App Password.

To do that login into your Google Account, choose Security entry on the left panel and click on App Passwords in Signing in to Google panel. If you do not see this item please consult corresponding thread on Google.

Click on Select app and choose desired application (usual called as Mail). Then click on Select device and choose the device, but it is better to add custom device and call it appropriately for easy future management. Then click on Generate and write down your App Password (16-character code in the yellow bar).

Warning: It is not possible to review or change app password later so use it immediately.

#### Configuration

    /etc/dma/dma.conf

    SMARTHOST smtp.gmail.com
    PORT 587
    AUTHPATH /etc/dma/auth.conf
    SECURETRANSFER
    STARTTLS
    MASQUERADE username@gmail.com

The MASQUERADE line ensures that mails sent by DMA appear to come from the specified user. Google will reject emails that do not come from the correct Google account.

    /etc/dma/auth.conf

    username@gmail.com|smtp.gmail.com:your-password

Note: Do not forget to specify your Google account login and password (or App Password instead, see #Prerequisites).

#### Minimalistic configuration with "null client"

If your use case is "all emails to be send to external mailbox(es) without any local delivery", the following configuration:

- Uses port 465 (TLS by default, always encrypted, no STARTTLS negotiation needed)
- Sends everything to Google SMTP server, bypassing any local mboxes.

    /etc/dma/dma.conf

    SMARTHOST smtp.gmail.com
    PORT 465
    AUTHPATH /etc/dma/auth.conf
    SECURETRANSFER
    MASQUERADE username@gmail.com
    NULLCLIENT

Category:

- Mail server