Configuring DirectAdmin to use Mailbaby as a smarthost is straightforward. DirectAdmin uses include files within exim.conf, which allows you to easily extend your mail configuration without overwriting the core setup.
Note on DirectAdmin 1.702+: The configuration line condition = "${perl{check_limits}}" has been completely removed as of DirectAdmin version 1.702. If your server is running DA 1.702 or newer, please omit this line when configuring your routers in Step 3.
Directadmin also publishes a smart host set up example at https://docs.directadmin.com/other-hosting-services/exim/smarthost.html
Step 1: Configure Authentication
First, create the file /etc/exim.authenticators.post.conf.
Add the following code, replacing YOURUSERNAME and YOURPASSWORD with your Mailbaby credentials. Your Mailbaby username is a single string and does not contain an @domain.com extension.
auth_login:
driver = plaintext
public_name = LOGIN
hide client_send = : YOURUSERNAME : YOURPASSWORD
Step 2: Set Up Outbound Transports
Next, edit or create /etc/exim.transports.pre.conf and add the configuration below to handle outbound SMTP connections:
auth_relay:
driver = smtp
port = 25
hosts_require_auth = $host_address
hosts_require_tls = $host_address
headers_add = "${if def:authenticated_id{X-AuthUser: ${authenticated_id}}}"
interface = <; ${if exists{/etc/virtual/domainips}{${lookup{$sender_address_domain}lsearch*{/etc/virtual/domainips}}}}
helo_data = ${if exists{/etc/virtual/helo_data}{${lookup{$sending_ip_address}iplsearch{/etc/virtual/helo_data}{$value}{$primary_hostname}}}{$primary_hostname}}
hosts_try_chunking =
hosts_try_fastopen =
.include_if_exists /etc/exim.dkim.conf
auth_relay_forward:
driver = smtp
port = 25
hosts_require_auth = $host_address
hosts_require_tls = $host_address
headers_add = "${if def:authenticated_id{X-AuthUser: ${authenticated_id}}}"
interface = <; ${if exists{/etc/virtual/domainips}{${lookup{$sender_address_domain}lsearch*{/etc/virtual/domainips}}}}
helo_data = ${if exists{/etc/virtual/helo_data}{${lookup{$sending_ip_address}iplsearch{/etc/virtual/helo_data}{$value}{$primary_hostname}}}{$primary_hostname}}
hosts_try_chunking =
hosts_try_fastopen =
max_rcpt = 1
return_path = ${srs_encode {SRS_SECRET} {$return_path} {$original_domain}}
.include_if_exists /etc/exim.dkim.conf
Step 3: Configure the Routers
Create /etc/exim.routers.pre.conf to route outbound mail through the Mailbaby network. (Remember to remove the perl{check_limits} condition line shown below if you are on DirectAdmin 1.702 or later).
smart_route_forward:
driver = manualroute
domains = ! +local_domains
ignore_target_hosts = 127.0.0.0/8
condition = ${if !eq{$original_domain}{$domain}}
condition = ${if !eq{$original_domain}{}}
transport = auth_relay_forward
route_list = * relay.mailbaby.net
no_more
smart_route:
driver = manualroute
domains = ! +local_domains
ignore_target_hosts = 127.0.0.0/8
condition = "${perl{check_limits}}"
transport = auth_relay
route_list = * relay.mailbaby.net
no_more