Use multiple smtp relay servers on directadmin

justusm

Verified User
Joined
Jun 15, 2023
Messages
6
Hi, i use an outbound going smtp for all the domains of my VPS. I want to set up an extra smtp for a specific domain only. So that it will be running next to my current settings. How can i arrange that? Now i use the following:

/etc/exim.authenticators.post.conf
auth_login:
driver = plaintext
public_name = LOGIN
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}}"
transport = auth_relay
route_list = * vps.transip.email::587
no_more

/etc/exim.transports.pre.conf
auth_relay:
driver = smtp
port = 587
hosts_require_auth = <; $host_address
hosts_require_tls = <; $host_address
 
I also checked the directadmin docs. But all configurations i can find, are the outbound smtp settings for the entire server. Maybe an if else statement we can use here?
 
Hello,

You can adjust /etc/exim.routers.pre.conf with the following condition:

Code:
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_relay_transip}{yes}}

and list domains in /etc/virtual/domains_relay_transip (one per line) emails from which should be relayed over TransIP.
 
Hello,

You can adjust /etc/exim.routers.pre.conf with the following condition:

Code:
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_relay_transip}{yes}}

and list domains in /etc/virtual/domains_relay_transip (one per line) emails from which should be relayed over TransIP.
Thank you for your comment zEitEr. That's not exactly what i want to set up. Now everything will be send over the transip mailserver. Thats the section i like to keep as it is. I use this settings for entire DA. I just need an extra smtp server for a specific customer.

I think i it will be the best to exclude the customer from the transip mailserver and add a new smtp server for the customer only.

So if i look at your code. It's only valid for the transip mailserver. am i right?
 
I just need an extra smtp server for a specific customer.

that would mean you should specify a list of domains for each router. It can be either a list of included or excluded domains.

- Use a router for listed domains:

Code:
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_over_relay}{yes}}

- Don't use a router for listed domains:

Code:
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_skip_relay}{no}{yes}}

The files /etc/virtual/domains_over_relay, /etc/virtual/domains_skip_relay and /etc/virtual/domains_relay_transip can have any other name. Just make sure they exist and can be read by Exim.

So if i look at your code. It's only valid for the transip mailserver. am i right?

That's just an example. You can update it to meet your needs.

You can check /etc/exim.conf for more examples and read official docs here: https://www.exim.org/exim-html-current/doc/html/spec_html/ch-generic_options_for_routers.html
 
that would mean you should specify a list of domains for each router. It can be either a list of included or excluded domains.

- Use a router for listed domains:

Code:
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_over_relay}{yes}}

- Don't use a router for listed domains:

Code:
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_skip_relay}{no}{yes}}

The files /etc/virtual/domains_over_relay, /etc/virtual/domains_skip_relay and /etc/virtual/domains_relay_transip can have any other name. Just make sure they exist and can be read by Exim.



That's just an example. You can update it to meet your needs.

You can check /etc/exim.conf for more examples and read official docs here: https://www.exim.org/exim-html-current/doc/html/spec_html/ch-generic_options_for_routers.html
I did just setup the following configuration:
/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

Unfortunately it doesn't work. Do you know what i am doing wrong?
 
Allright. i changed the nslookup but it still transports e-mails from the domain to auth_relay and not nfvm_relay. I placed the domain in the file domains_skip_relay and domains_over_relay

/etc/exim.routers.pre.conf
transip_email:
driver = manualroute
domains = !+local_domains
#senders = !: !*@nfvm.nl
ignore_target_hosts = 127.0.0.0/8
condition = "${perl{check_limits}}"
condition = ${lookup{$sender_address_domain}lsearch{/etc/virtual/domains_skip_relay}{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}lsearch{/etc/virtual/domains_over_relay}{yes}}
transport = nfvm_relay
route_list = * mail.smtp2go.com::587
no_more

When i check the exim mainlog i see this:
2023-08-04 11:13:39 1qRqsN-0051yS-0v auth_login authenticator failed H=mail.smtp2go.com [139.162.187.151] 535 Incorrect authentication data
2023-08-04 11:13:39 1qRqsN-0051yS-0v auth_login authenticator failed H=mail.smtp2go.com [176.58.103.10] 535 Incorrect authentication data
2023-08-04 11:13:39 1qRqsN-0051yS-0v == [email protected] R=nfvm_email T=nfvm_relay defer (-42): authentication required but authentication attempt(s) failed
 
Hi @justusm,
Can you please confirm how you've fixed this authentication issue? I have followed the same guidelines but 2nd smtp relay using the first "smtp login details I doubt, so that I'm getting the same error that was mentioned above". I followed everything as mentioned here but no luck.

I will really appreciate if you could share the hint to get the authentication issue resolved. Like each router use its authencation detail "user/pass" saved in exim.authenticators.post file.
 
Like each router use its authencation detail "user/pass" saved in exim.authenticators.post file.

The method widely suggested here on the forums, in DirectAdmin help pages, and in internet is not suitable for a case when you want to use 2 or more SMTP relays with different username/password combinations. You might use extract command of Exim and a separate file with SMTP relay settings.

- https://www.exim.org/exim-html-current/doc/html/spec_html/ch-string_expansions.html
 
Back
Top