The Geek Bin

Configuring your DirectAdmin server to use Amazon SES

I’ve recently migrated from Plesk to DirectAdmin, and one of the things I wanted to configure was Amazon SES for sending emails through my server. I prefer SES due to the pay-as-you-go model. In one month if I send zero emails, I’d rather not be paying for emails, so this model let’s me have the flexibility I want for fractions of the cost of normal relays.

DirectAdmin uses exim for sending out email, unlike most setups using Postfix (eg, Plesk). In Postfix, it’s as simple as editing the smart host property and pushing in your credentials. In order to configure DirectAdmin for sending with SES in exim, you should sign-in to your server as root and execute the following commands:

cd /etc/
wget -O /etc/exim.routers.pre.conf http://files.directadmin.com/services/SpamBlocker/smart_route/exim.routers.pre.conf
wget -O /etc/exim.transports.pre.conf http://files.directadmin.com/services/SpamBlocker/smart_route/exim.transports.pre.conf
wget -O /etc/exim.authenticators.post.conf http://files.directadmin.com/services/SpamBlocker/smart_route/exim.authenticators.post.conf

What we’re doing is downloading the configuration files we’ll need to modify in order to get SES to work with our setup. Start by editing the file exim.authenticators.post.conf in /etc/ directory. Here’s what it should look like:

auth_login:
    driver = plaintext
    public_name = LOGIN
    hide client_side = : SMTP_USERNAME : SMTP_PASSWORD

The SMTP username and password can be obtained from the SES dashboard when creating credentials. Now, you’ll want to save the file and edit exim.authenticators.post.conf, you’ll want to enter ensure it looks similar to this:

smart_route:
    driver = manualroute
    domains = ! +local_domains
    ignore_target_hosts = 127.0.0.0/8
    condition = "${perl{check_limits}}"

    transport = auth_relay

    route_list = * email-smtp.{region}.amazonaws.com
    no_more

Substitute your region in as necessary, in my case it’s us-east-1, so the route_list would be email-smtp.us-east-1.amazonaws.com.

Now, you’ve configured exim, execute systemctl restart exim to apply the changes. Once you’ve done that, all your domains emails will be sent directly through Amazon SES. Make sure you’re out of sandbox mode on SES and you’ve verified your domains on SES that DirectAdmin is hosting, then you’re good to send emails!

I hope this works for you and you enjoyed the tutorial. If you did, feel free to leave a comment below! If it didn’t work for you, let me know and I’ll revisit to see if anything has changed and update the tutorial as necessary!

Add Comment