> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mailchannels.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Setup DirectAdmin

> Configure Exim in DirectAdmin to relay outbound mail through MailChannels Outbound Filtering using SMTP authentication and smart host settings.

This guide walks you through configuring Exim on a DirectAdmin server to relay all outbound mail through MailChannels Outbound Filtering.

## Prerequisites

* Root or `sudo` access to your DirectAdmin server
* Your MailChannels SMTP username and password

## Exim 4.5.7 and later

<Steps>
  <Step title="Create the router configuration">
    Create `/etc/exim.routers.pre.conf` with the following content:

    ```text /etc/exim.routers.pre.conf theme={null}
    smart_route:
      driver = manualroute
      domains = ! +local_domains
      ignore_target_hosts = 127.0.0.0/8
      condition = "${perl{check_limits}}"
      transport = auth_relay
      route_list = * smtp.mailchannels.net::25
      no_more
    ```
  </Step>

  <Step title="Create the transport configuration">
    Create `/etc/exim.transports.pre.conf` with the following content:

    ```text /etc/exim.transports.pre.conf theme={null}
    auth_relay:
      driver = smtp
      headers_add = X-AuthUser: $authenticated_id
      hosts_require_auth = $host_address
      hosts_require_tls = $host_address
    ```

    <Note>
      The `X-AuthUser` header identifies the authenticated sender. MailChannels uses it to track per-sender reputation. Messages without this header are treated as forwarded mail and subject to different policies.
    </Note>
  </Step>

  <Step title="Create the authenticator configuration">
    Create `/etc/exim.authenticators.post.conf` with the following content, replacing the placeholders with your actual MailChannels SMTP credentials:

    ```text /etc/exim.authenticators.post.conf theme={null}
    auth_login:
      driver = plaintext
      public_name = LOGIN
      hide client_send = : smtpusername : smtppassword
    ```
  </Step>

  <Step title="Restart Exim">
    ```bash theme={null}
    service exim restart
    ```
  </Step>
</Steps>

## Exim prior to 4.5.7

<Warning>
  Exim versions prior to the current major release are considered obsolete by the Exim development team. Upgrading to a current release is strongly recommended.
</Warning>

With older DirectAdmin installations, Exim configuration is stored in a single file at `/etc/exim.conf`. Make the following changes to that file.

<Steps>
  <Step title="Add the authenticator">
    In the `begin authenticators` section, add the following block, replacing the placeholders with your actual MailChannels SMTP credentials:

    ```text /etc/exim.conf theme={null}
    auth_login:
      driver = plaintext
      public_name = LOGIN
      hide client_send = : smtpusername : smtppassword
    ```
  </Step>

  <Step title="Add the router">
    At the top of the `begin routers` section, add the following block:

    ```text /etc/exim.conf theme={null}
    send_via_mailchannels:
      driver = manualroute
      domains = ! +local_domains
      senders = !*@domain1.to.exclude.com : !*@domain2.to.exclude.com
      ignore_target_hosts = 127.0.0.0/8
      condition = "${perl{check_limits}}"
      transport = auth_relay
      route_list = * smtp.mailchannels.net
      no_more
    ```

    If you do not need to exclude any senders or domains from the relay, leave the `senders =` line blank or remove it entirely.

    <Note>
      Do not remove or comment out the `lookuphost:` router. It handles delivery for any domains excluded from the MailChannels relay and routes them directly from the DirectAdmin server.
    </Note>
  </Step>

  <Step title="Add the transport">
    In the `begin transports` section, add the following block:

    ```text /etc/exim.conf theme={null}
    auth_relay:
      driver = smtp
      port = 25
      headers_add = X-AuthUser: $authenticated_id
      hosts_require_auth = $host_address
      hosts_require_tls = $host_address
    ```
  </Step>

  <Step title="Restart Exim">
    ```bash theme={null}
    service exim restart
    ```
  </Step>
</Steps>
