Exim smarthost recipient DNS lookups

Operating System & Version
Centos 7.9
cPanel & WHM Version
94.05

RVI

Registered
Feb 4, 2017
2
0
1
uk
cPanel Access Level
Root Administrator
Exim version: 4.94-2.cp1194
WHM 94.05, Centos 7

Hi, I've setup Exim to send some emails (those which include a special header) via a smarthost. This is the router setup:

===========================================
send_via_smarthost:
driver = manualroute
domains = ! +local_domains
condition = ${if def:header_X-xsMailingId:{true}{}}
transport = smarthost_smtp
route_list = "* smtp.smarthost.com::587 byname"
host_find_failed = defer
no_more
===========================================

This all works fine, but Exim is still doing a DNS lookup for each recipient domain. I assumed that in this case, Exim would just route the email to the smarthost and it would be the smarthost which would do the MX lookups. Is my assumption correct? If this is Exim's intended behaviour, is there a setting to tell Exim to skip DNS lookups for the recipient in this case?

I know that it's doing a lookup on the recipient because I see lines like this in the log:
====
temporarily rejected RCPT <[email protected]>: host lookup did not complete
====

The reason I want to skip DNS lookups when routing via a smarthost is to speed up my scripts. With thousands of recipients, many of them with custom domains, even with a local caching name server, lookups to these domains can take tens, or sometimes hundreds, of miliseconds.

Many thanks for any help or advice anyone can give me.
 

cPDavidL

Linux Analyst II
Staff member
Oct 15, 2012
79
17
133
cPanel Access Level
Root Administrator
Howdy, RVI!

Indeed that is intended behavior. However, it can be configured to skip dns.

To quote exim documentation: 20. The manualroute router

Addresses with the same domain are normally routed by the manualroute router to the same list of hosts. However, this cannot be presumed, because the router options and preconditions may refer to the local part of the address. By default, therefore, Exim routes each address in a message independently. DNS servers run caches, so repeated DNS lookups are not normally expensive, and in any case, personal messages rarely have more than a few recipients.
For more information about dnslookup: 51. Some common configuration settings
 

RVI

Registered
Feb 4, 2017
2
0
1
uk
cPanel Access Level
Root Administrator
Hi David. Thanks very much. Is it the " same_domain_copy_routing" setting that you're referring to? I understood that to mean that the first time that Exim comes across a domain, it will do a DNS lookup, then if same_domain_copy_routing is set, it will skip subsequent lookups to the same domain. But it will always do one lookup per domain.

If message delivery is via another host, then there shouldn't be a need to do even one lookup on the recipient's domain since Exim won't be handling delivery of the message - it'll be the smarthost that does this. Doing this lookup is wasted effort as far as I can see. I couldn't find a setting which tells Exim to skip DNS lookup of the recipient altogether.
 

cPRex

Jurassic Moderator
Staff member
Oct 19, 2014
4,836
597
273
cPanel Access Level
Root Administrator
That sounds correct to me. Here's a section of the Exim docs here:


"Addresses with the same domain are normally routed by the manualroute router to the same list of hosts. However, this cannot be presumed, because the router options and preconditions may refer to the local part of the address. By default, therefore, Exim routes each address in a message independently. DNS servers run caches, so repeated DNS lookups are not normally expensive, and in any case, personal messages rarely have more than a few recipients.

If you are running mailing lists with large numbers of subscribers at the same domain, and you are using a manualroute router which is independent of the local part, you can set same_domain_copy_routing to bypass repeated DNS lookups for identical domains in one message. In this case, when manualroute routes an address to a remote transport, any other unrouted addresses in the message that have the same domain are automatically given the same routing without processing them independently. However, this is only done if headers_add and headers_remove are unset."