# This router routes addresses that are not in local domains by doing a DNS
# lookup on the domain name. The exclamation mark that appears in "domains = !
# +local_domains" is a negating operator, that is, it can be read as "not". The
# recipient's domain must not be one of those defined by "domainlist
# local_domains" above for this router to be used.
#
# If the router is used, any domain that resolves to 0.0.0.0 or to a loopback
# interface address (127.0.0.0/8) is treated as if it had no DNS entry. Note
# that 0.0.0.0 is the same as 0.0.0.0/32, which is commonly treated as the
# local host inside the network stack. It is not 0.0.0.0/0, the default route.
# If the DNS lookup fails, no further routers are tried because of the no_more
# setting, and consequently the address is unrouteable.

dnslookup_with_dkim:
  debug_print = "R: dnslookup_with_dkim for $local_part@$domain (using $sender_address_domain)"
  driver = dnslookup
  condition = ${if and{ \
                {exists{VHOST_DIR/$sender_address_domain/VHOST_CONFIG_DIR/dkim}} \
                {exists{VHOST_DIR/$sender_address_domain/VHOST_CONFIG_DIR/dkim.key}} \
              }}
  domains   = ! +local_domains
  transport = remote_smtp_with_dkim
  same_domain_copy_routing = yes
  ignore_target_hosts = +private_addresses
  no_more

