Introduction

If you want to configure your DirectAdmin server to send all outgoing mail through an external SMTP server (also called a smarthost), you’ll need to modify Exim’s configuration accordingly. This setup allows you to route email through services like relay.stacksmtp.com with proper authentication and encryption.

Prerequisites

  • Hostname of the SMTP relay — e.g., relay.stacksmtp.com
  • SMTP authentication credentials (username and password)
  • DirectAdmin root or admin access (SSH + panel)
  • Ports 587 or 465 open in the firewall
  • Exim is being used (default in DirectAdmin)

Step 1: SSH into Your Server

Access your DirectAdmin server via SSH as root:

ssh root@your_server_ip

Step 2: Edit Exim Configuration

Open the Exim configuration override file:

nano /etc/exim.auth.conf.custom

Add your relay server credentials (replace with actual values):

begin authenticators

smtp_relay:
  driver = plaintext
  public_name = LOGIN
  client_send = : your_username : your_password

Step 3: Set the Smart Host (SMTP Relay)

Now edit or create the routing file:

nano /etc/exim.routers.pre.conf

Add the following:

send_via_relay:
  driver = manualroute
  domains = ! +local_domains
  transport = relay_smtp
  route_list = * relay.stacksmtp.com::587
  host_find_failed = defer
  no_more

Step 4: Define the Transport

Edit or create the transport file:

nano /etc/exim.transports.pre.conf

Add:

relay_smtp:
  driver = smtp
  port = 587
  hosts_require_auth = *
  hosts_require_tls = *

Step 5: Rebuild and Restart Exim

Apply your custom configuration by running:

cd /usr/local/directadmin/custombuild
./build exim_conf
systemctl restart exim

Step 6: Test Your Configuration

Send a test email:

echo "Test message from DirectAdmin" | mail -s "SMTP Relay Test" recipient@example.com

Conclusion

You’ve now successfully configured your DirectAdmin server to relay outgoing mail through relay.stacksmtp.com using SMTP authentication and TLS. This improves deliverability, security, and centralizes mail handling through a trusted SMTP gateway.

Was this answer helpful? 0 Users Found This Useful (0 Votes)