How to choose a smarthost based on From: address in exim4 on Debian

Solution 1:

OK, I got it. senders is what /etc/mailname provides, not the domain part of the From:

The following works:

smarthost_server2:
  debug_print = "R: smarthost_server2 for $local_part@$domain"
  driver = manualroute
  domains = ! +local_domains
  transport = remote_smtp_smarthost
  condition = ${if match_domain{${domain:$h_From:}}{smtp.server2.com}{yes}{no}} 
  route_list = * smtp.server2.com byname
  host_find_failed = ignore
  same_domain_copy_routing = yes
no_more

Notice the condition that extracts the domain name out of the From: header and compares it with smtp.server2.com.