Mailing List Archive

Routing instead of smarthost
Hi!

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 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?

Is there any useful example for this?

Regards
tovis

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
On 2022-05-19 19:01, R-VISOR-TOVIS via Exim-users wrote:
> Hi!
>
> 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 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?
>
> Is there any useful example for this?
>
> Regards
> tovis

Hi. As I understand you need one or more "manualroute routers".
From Exim doc:
"The manualroute router is so-called because it provides a way of
manually routing an address according to its domain. It is mainly used
when you want to route addresses to remote hosts according to your own
rules, bypassing the normal DNS routing that looks up MX records."

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
On 5/20/22 00:01, R-VISOR-TOVIS via Exim-users wrote:
> Hi!
>
> 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".


If you're using Debian's exim configuration facility, then first you need to switch to custom configuration. As root:

# cp /var/lib/exim4/config.autogenerated /etc/exim4/exim4.conf

Now find the following section:

.ifdef DCconfig_smarthost DCconfig_satellite

smarthost:
  debug_print = "R: smarthost for $local_part@$domain"
  driver = manualroute
  domains = ! +local_domains
  transport = remote_smtp_smarthost
  route_list = * DCsmarthost byname
  host_find_failed = ignore
  same_domain_copy_routing = yes
  no_more

.endif

Change the route_list:

route_list = gmail.com gmail.your.smarthost ; \
    outlook.com ms-1.your.smarthost:ms-2.your.smarthost ; \
    example.com another.smarthost ; \
    * your.default.smarthost

In this example you have two possible smarthosts for outlook.com, separated by a colon

If you need to specify a port, it would look like this:

route_list = gmail.com gmail.your.smarthost::587 ; \
    outlook.com "ms-1.your.smarthost::587 : ms-2.your.smarthost::587" ; \
    example.com another.smarthost::587 ; \
    * your.default.smarthost::587

Then make sure to add credentials to /etc/exim4/passwd.client :

a.smart.host:username:password

See https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_manualroute_router.html#SECID120



--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
2022-05-20 13:02 id?pontban Gedalya ezt írta:
> On 5/20/22 00:01, R-VISOR-TOVIS via Exim-users wrote:
>> Hi!
>>
>> 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".
>
>
> If you're using Debian's exim configuration facility, then first you
> need to switch to custom configuration. As root:
>
> # cp /var/lib/exim4/config.autogenerated /etc/exim4/exim4.conf
>
> Now find the following section:
>
> ifdef DCconfig_smarthost DCconfig_satellite
>
> smarthost:
>   debug_print = "R: smarthost for $local_part@$domain"
>   driver = manualroute
>   domains = ! +local_domains
>   transport = remote_smtp_smarthost
>   route_list = * DCsmarthost byname
>   host_find_failed = ignore
>   same_domain_copy_routing = yes
>   no_more
>
> endif
>
> Change the route_list:
>
> route_list = gmail.com gmail.your.smarthost ; \
>     outlook.com ms-1.your.smarthost:ms-2.your.smarthost ; \
>     example.com another.smarthost ; \
>     * your.default.smarthost
>
> In this example you have two possible smarthosts for outlook.com,
> separated by a colon
>
> If you need to specify a port, it would look like this:
>
> route_list = gmail.com gmail.your.smarthost::587 ; \
>     outlook.com "ms-1.your.smarthost::587 : ms-2.your.smarthost::587" ;
> \
>     example.com another.smarthost::587 ; \
>     * your.default.smarthost::587
>
> Then make sure to add credentials to /etc/exim4/passwd.client :
>
> a.smart.host:username:password
>
> See
> https://www.exim.org/exim-html-current/doc/html/spec_html/ch-the_manualroute_router.html#SECID120

Thank you for response!

In /etc/exim4/passwd.client file I can place many rows?

> a.smart.host:username:password
b.smart.host:username:password
c.smart.host:username:password

If that working, it would be great!

Regards
tovis


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
On 5/20/22 21:42, R-VISOR-TOVIS wrote:
> Thank you for response!
>
> In /etc/exim4/passwd.client file I can place many rows?
>
>> a.smart.host:username:password
>   b.smart.host:username:password
>   c.smart.host:username:password

Yes, you must in fact include an entry for every smarthost used. If they happen to all have the same credentials then you can just use one line:

*:user:password

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
2022-05-20 15:44 id?pontban Gedalya via Exim-users ezt írta:
> On 5/20/22 21:42, R-VISOR-TOVIS wrote:
>> Thank you for response!
>>
>> In /etc/exim4/passwd.client file I can place many rows?
>>
>>> a.smart.host:username:password
>>   b.smart.host:username:password
>>   c.smart.host:username:password
>
> Yes, you must in fact include an entry for every smarthost used. If
> they happen to all have the same credentials then you can just use one
> line:
>
> *:user:password
Great!

One more short question.
Is it enough if I save (now working as is) configuration from /etc/ecim4
?

Regards
tovis

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
On 5/20/22 22:05, R-VISOR-TOVIS wrote:
> One more short question.
> Is it enough if I save (now working as is) configuration from /etc/ecim4 ?

I don't quite understand, sorry! :-)


--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
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

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
2022-05-20 16:08 id?pontban Gedalya ezt írta:
> On 5/20/22 22:05, R-VISOR-TOVIS wrote:
>> One more short question.
>> Is it enough if I save (now working as is) configuration from
>> /etc/ecim4 ?
>
> I don't quite understand, sorry! :-)
Sorry!

In Debian seems to be all configuration files (there are) for exim in
the directory
/etc/exim4
Is it enough to save every thing from this directory, it would be enough
to restore the exim configuration?
(Could be not so simple)

Regards
tovis

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
On 5/20/22 22:16, R-VISOR-TOVIS wrote:
>
> In Debian seems to be all configuration files (there are) for exim in the directory
> /etc/exim4
> Is it enough to save every thing from this directory, it would be enough to restore the exim configuration?

Almost enough.

Other files that can affect exim's behavior are /etc/email-addresses, /etc/aliases

When the file /etc/exim4/exim4.conf exists, then Debian's exim will use it in preference over the autogenerated /var/lib/exim4/config.autogenerated, and also the autogeneration scripts no nothing.

/etc/exim4/passwd.client is used for the smarthost, and that's really about it.

As for exim _state_, it's all under /var/spool/exim4/, the most important being any messages on the queue.

(For future record, take this in context, we're talking about a Debian configuration only slightly modified)



--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
On 5/20/22 22:10, exim-users--- via Exim-users wrote:
> 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).

These days, the network you're coming from is a very important factor. A subscriber network (business / residential) or so-called "cloud" networks are considered bad reputation, this often applies to the entire network and not to a specific IP address. It can be very difficult to get your mail through, even if you follow the recommendations wrt DKIM, DMARC etc.

The motivation to use a smarthost is clear.

> 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):
>

> 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)):

> If necessary, you can put credentials for authorization into /etc/exim4/password.client (one per line).

The remote_smtp transport does not use password.client. remote_smtp_smarthost does.

You can indeed use the hubbed hosts setup, it makes sense to edit /etc/exim4/hubbed_hosts rather than the main config file, but you'd just have to change the transport to remote_smtp_smarthost and then authentication would work.



--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
Hi Gedalya,

On 20.05.22 16:33, Gedalya via Exim-users wrote:
> On 5/20/22 22:10, exim-users--- via Exim-users wrote:
>> 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).

> These days, the network you're coming from is a very important factor. A subscriber network (business / residential) or so-called "cloud" networks are considered bad reputation, this often applies to the entire network and not to a specific IP address. It can be very difficult to get your mail through, even if you follow the recommendations wrt DKIM, DMARC etc.
> The motivation to use a smarthost is clear.

You are right with that (especially with the network reputation), however the OP might replicate that "send direct" setup. I think configuring a lot manual routes instead of one (or a low
number) of smarthosts is getting unhandy really fast.
> The remote_smtp transport does not use password.client. remote_smtp_smarthost does.
>
> You can indeed use the hubbed hosts setup, it makes sense to edit /etc/exim4/hubbed_hosts rather than the main config file, but you'd just have to change the transport to remote_smtp_smarthost and then authentication would work.

Thanks for pointing that out, I indeed changed the transport for my hubbed_hosts setup (some time ago). I like the approach of route lookup, because I try to avoid editing the config file for
possibly regularly changing parts (and it helps on updates, if the main configuration does not have to many changes).

Regards,
Thomas

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/
Re: Routing instead of smarthost [ In reply to ]
2022-05-20 16:33 id?pontban Gedalya via Exim-users ezt írta:
> On 5/20/22 22:10, exim-users--- via Exim-users wrote:
>> 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).
>
> These days, the network you're coming from is a very important factor.
> A subscriber network (business / residential) or so-called "cloud"
> networks are considered bad reputation, this often applies to the
> entire network and not to a specific IP address. It can be very
> difficult to get your mail through, even if you follow the
> recommendations wrt DKIM, DMARC etc.
>
> The motivation to use a smarthost is clear.
>
>> 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):
>>
>
>> 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)):
>
>> If necessary, you can put credentials for authorization into
>> /etc/exim4/password.client (one per line).
>
> The remote_smtp transport does not use password.client.
> remote_smtp_smarthost does.
>
> You can indeed use the hubbed hosts setup, it makes sense to edit
> /etc/exim4/hubbed_hosts rather than the main config file, but you'd
> just have to change the transport to remote_smtp_smarthost and then
> authentication would work.

Hi!
About a year ago (after trying to setup my own smart host) I was found a
service provider for reasonable price. At first time it was work well I
was happy with all of my accounts. But now, I have more and more
partners, who haven't got my emails, even as a spam.
But, if I use my account providers web mail system my emails are
accepted.

Most important, that I need more complicated setup and I need to do more
preparation for change.

Thank you, I would back if I have results.
Regards
tovis

--
## List details at https://lists.exim.org/mailman/listinfo/exim-users
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/