[Pkg-exim4-users] selecting smarthost based on sender address

J G Miller miller at yoyo.ORG
Sat May 30 20:03:17 UTC 2015

At 14:02h, on Friday, May 29, 2015,
in message <20150529120216.GB5059 at hans>,
on the subject of "[Pkg-exim4-users] selecting smarthost based on sender address",
Hans Ekbrand explained:

 > However, I used the concept outlined there and tried to apply it to
 > exim4 with split config.

The exim4 configuration with lots of macro variables for turning on and off features
is very good for black box operation where the user only wants to use one of the defined
models of operation, so my suggestion for anybody wishing to do a custom setup is to keep
things simple, and although keeping the split format with all the individual files for each
section, remove all the macro tests keeping only things that you need, and just define simple
macro variables with values specific to your case.

No doubt the Debian maintainer will strongly object to this suggestion, but it results in
following what is happening and debugging being much simpler, and it means you will have
some familiarity with what is actually happening in each file if you have reviewed each one.

 > 2015-05-29 12:47:52 [22622] 1YyHpQ-0005sq-AT error in smarthost router: no host(s) specified for domain *

Looking at router/200_exim4-config_primary, my guess that this is coming from

      route_list = * DCsmarthost byname

and that the macro variable DCsmarthost is not defined, hence the error message

           "no host(s) specified for domain *"

So I would suggest you check to see if DCsmarthost is defined. Is it beacause you are
using dc_smarthost and not CDsmarthost?

Check to see what has been generated in the unified configuration file sans macros
in /var/lib/exim4/config.autogenerated for missing parameters and ill-formed statements.

And as a bonus, here is a way to get your external ISP hostname into your headers rather than
using the internal hostname.

In router/200_exim4-config_primary, where MAIN_SMTP_SMARTHOST is defined as the ISP mailer,
/etc/exim4/conf.d/main/01_exim4-config_listmacrosdefs  (this is what I meant about just using
simple macro variables names)

        driver                          = manualroute
        debug_print                     = "Router: smarthost for $local_part@$domain"
        address_data                    = ${lookup dnsdb{ptr=${run{/usr/local/share/sh/external_ip}}}{$value}{localhost}}
        domains                         = !+local_domains
        host_find_failed                = ignore
        route_list                      = * MAIN_SMTP_SMARTHOST byname
        same_domain_copy_routing        = yes
        transport                       = remote_smtp_smarthost

and then in /etc/exim4/conf.d/transport/30_exim4-config_remote_smtp_smarthost

        driver                  = smtp
        debug_print             = "Transport: remote_smtp_smarthost for $local_part@$domain"
        helo_data               = $address_data
        headers_remove          = Received:Message-Id
        headers_add             = "Message-Id: <$message_id@$address_data>"
        headers_rewrite         = CHECK_HEADERS_REWRITE \
        hosts_try_auth          = <; \
                                  ${if exists{CONFDIR/passwd.client}\
        return_path             = ${if match{$return_path}{CHECK_RETURN_PATH}\
        tls_certificate         = TLS_SMARTHOST_CERTIFICATE
        tls_dh_min_bits         = TLS_DH_MIN_BITS

This results in the mailer getting a HELO message from the real external hostname as assigned by
the ISP and not the fictitious internal to one's lan hostname.domain.  Obviously you need the
shell script to lookup the external address using curl and dig.

More information about the Pkg-exim4-users mailing list