Re: [exim] Routing instead of smarthost

Top Page
Delete this message
Reply to this message
Author: exim-users
Date:  
To: exim-users
Subject: Re: [exim] Routing instead of smarthost
Hi Tovis,

On 19.05.22 18:01, R-VISOR-TOVIS via Exim-users wrote:
> I'm running exim 4.92-8+deb10u6 on Debian version 10.11
> Default configuration "smart_host"
>
> Unfortunately, with more and more restrictions in mailing systems I need to address every emails to appropriate smtp server, not one "smart host".


I would check if it is possible to get rid of the smarthost style config completely and configure as "internet site; mail is sent and received directly
using SMTP". Exim will lookup MX for outgoing mail in DNS and take care of delivery without any manual configuration. You should implement the usual stuff
to get your mail properly accepted and not marked as SPAM (you should do that anyways).

If you need only some manual routes, Debian has a (imho) nice default configuration prepared for that, which is called hubbed hosts (relevant part of
exim4.conf.template):

# route specific domains manually.
#
# see exim4-config_files(5) and spec.txt chapter 20.3 through 20.7 for
# more detailed documentation.

   hubbed_hosts:
     debug_print = "R: hubbed_hosts for $domain"
     driver = manualroute
     domains = "${if exists{CONFDIR/hubbed_hosts}\
                      {partial-lsearch;CONFDIR/hubbed_hosts}\
                 fail}"
     same_domain_copy_routing = yes
     route_data = ${lookup{$domain}partial-lsearch{CONFDIR/hubbed_hosts}}
     transport = remote_smtp


You only need to create /etc/exim4/hubbed_hosts and put a pair of destiantion domain and mailserver(s) per line, (quoting exim4-config_files(5)):

   /etc/exim4/hubbed_hosts
       [exim  domain  list] is an optional file containing a list of route_data records which can be used to override
       or augment MX information from the DNS. This is particularly useful for mail hubs which  are  highest-priority
       MX  for  a domain in the DNS but are not final destination of the messages, passing them on to a host which is
       not publicly reachable, or to temporarily fix mail routing in case of broken DNS setups.


       The file should contain key-value pairs of domain pattern and route data of the form


       domain: host-list options
       dict.ref.example:  mail-1.ref.example:mail-2.ref.example
       foo.example: internal.mail.example.com
       bar.example: 192.168.183.3


       which will cause mail for foo.example to be sent to the host internal.mail.example (IP address derived from  A
       record only), and mail to bar.example to be sent to 192.168.183.3.


       See  spec.txt  chapter 20.3 through 20.7 for a more detailed explanation of host list format and available op‐
       tions.


> I do not have enough practice, on some forum I have got a suggestion to build/setup different "routs".
> Could I do that? - sending emails of different domains to appropriate smtp server?


Main issue will be to put all relevant domains into hubbed_hosts an keep that file up to date (if destination MX changes you will need to update it).
If necessary, you can put credentials for authorization into /etc/exim4/password.client (one per line).

> Is there any useful example for this?


Documentation referenced in the config contains examples, which are good enough to give the idea for a individual setup (imho).

hth,
Thomas