Using Multiple SMTP servers on Directadmin

mr.ken84

Verified User
Joined
Apr 21, 2022
Messages
17
On my DA machine there are many domains, I want to use two smtp relay servers,
ex: relay google (Relay A) and smtp2go (relay b).
I want to specify that some domains run relay through Relay A, some domains run through Relay B
I installed it like that on the server, but got the error SMTP Error (): Connection to server failed.
Can someone help me install 2 relay servers on directadmin

/etc/exim.authenticators.post.conf

auth_login:
driver = plaintext
public_name = LOGIN
client_send = : username : password
server_set_id = $1

nfvm_login:
driver = plaintext
public_name = NFVM
client_send = : username : password
server_set_id = $1

/etc/exim.routers.pre.conf

transip_email:
driver = manualroute
domains = !+local_domains
ignore_target_hosts = 127.0.0.0/8
condition = "${perl{check_limits}}"
condition = ${lookup{$sender_address_domain}nfvm.nl{no}{yes}}
transport = auth_relay
route_list = * vps.transip.email::587
no_more

nfvm_email:
driver = manualroute
domains = !+local_domains
ignore_target_hosts = 127.0.0.0/8
condition = "${perl{check_limits}}"
condition = ${lookup{$sender_address_domain}nfvm.nl{yes}}
transport = nfvm_relay
route_list = * mail.smtp2go.com::587
no_more

/etc/exim.transports.pre.conf

auth_relay:
driver = smtp
port = 587
hosts_require_auth = <; $host_address
hosts_require_tls = <; $host_address

nfvm_relay:
driver = smtp
port = 587
hosts_require_auth = <; $host_address
hosts_require_tls = <; $host_address
hosts_try_auth = nfvm_login
 
Please remove the "solved" prefix from your first post, otherwise people think it's solved and you get no answer.
I can't help you with this by the way.
 
Here is what I have been using to allow different domains to use different relays.

/etc/exim.authenticators.post.conf
Code:
auth_login:
    driver = plaintext
    public_name = LOGIN
    hide client_send = : ${extract{user}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}: ${extract{pass}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}

/etc/exim.routers.pre.conf
Code:
smart_route_forward:
    driver = manualroute
    domains = ! +local_domains
    condition =  "${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/exim_smarthosts}{$value}}}{}{false}{true}}"
    ignore_target_hosts = 127.0.0.0/8
    condition = ${if !eq{$original_domain}{$domain}}
    condition = ${if !eq{$original_domain}{}}
    condition = "${perl{check_limits}}"
    
    transport = auth_relay_forward

    route_list = * ${extract{smtp}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}
    no_more

smart_route:
    driver = manualroute
    domains = ! +local_domains
    condition =  "${if eq{${lookup{$sender_address_domain}partial-lsearch{/etc/exim_smarthosts}{$value}}}{}{false}{true}}"
    ignore_target_hosts = 127.0.0.0/8
    condition = "${perl{check_limits}}"

    transport = auth_relay

    route_list = * ${extract{smtp}{${lookup{$sender_address_domain}lsearch{/etc/exim_smarthosts}}}}
    no_more

/etc/exim.transports.pre.conf
Code:
auth_relay:
    driver = smtp
    message_linelength_limit = 52428800
    port = 25
    hosts_require_auth = $host_address
    hosts_require_tls = $host_address
    headers_add = "${if def:authenticated_id{X-Authenticated-Id: ${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
    message_linelength_limit = 52428800
    port = 25
    hosts_require_auth = $host_address
    hosts_require_tls = $host_address
    headers_add = "${if def:authenticated_id{X-Authenticated-Id: ${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

This is where I define which domain uses which relay:
/etc/exim_smarthosts
Code:
example.com: domain=example.com user=myrelayusername pass=myrelaypassword smtp=relay.com
example2.com: domain=example2.com user=2ndrelayusername pass=2ndrelaypassword smtp=relay2.net
 
Thanks @beachfront and it works fine.
How to do it will take time because I have quite a few domains on the server
How can I set the default Relay for the entire domain, meaning that if the domain is not set to exim_smarthosts, then the relay will be via the default account?
 
Glad it helped.

I'm afraid I don't know how to set a default Relay - on mine the default is to send out from the server rather than use a relay. It has been so long since I set it up that I just don't remember the details enough - and it took a quite a bit of trial and error to get it working.

The thing that helped the most was this thread and specifically the post from mxroute
https://forum.directadmin.com/threads/how-to-get-userbased-smarthost-running.55829/#post-328977

Maybe some of the information there will help you work out how to set a default.
 
Back
Top