如何根据 Debian 上 exim4 中的 From: 地址选择智能主机

mik*_*ian 5 smtp exim smarthost

我要路由邮件与发件人:.*@host1.com通过smtp.server1.com和电子邮件与发件人:.*@host2.com通过smtp.server2.com

目前,我已经配置了 smarthostdpkg-reconfigure exim4-config以便update-exim4.conf.conf包含行 dc_smarthost='smtp.server1.com::587'. 也就是说,一切都通过smtp.server1.com.

我尝试smarthost:在配置文件中的定义之前添加另一个路由器,设置senders = .*@host2.com

smarthost_server2:
  debug_print = "R: smarthost_server2 for $local_part@$domain"
  driver = manualroute
  domains = ! +local_domains
  transport = remote_smtp_smarthost
  senders = .*@host2.com
  route_list = * smtp.server2.com byname
  host_find_failed = ignore
  same_domain_copy_routing = yes
no_more
Run Code Online (Sandbox Code Playgroud)

但 exim 仍然通过smtp.server1.com. 我senders是否正确使用了条件?

AFAIU,对于有电子邮件的人来说,这应该是一种相当常见的设置。@google.com 和 . @gmail.com 不想在他们的 @gmail.com 电子邮件标题中透露他们也是谷歌员工的事实,所以路由应该不同。

mik*_*ian 5

好,我知道了。senders是 /etc/mailname 提供的内容,而不是 From 的域部分:

以下作品:

begin routers

smarthost1:
  driver = manualroute
  domains = ! +local_domains
  condition = ${if match_domain{${domain:$h_From:}}{domain.com}{yes}{no}}
  transport = remote_domain_com_smtp
  route_data = domain.com::587
  ignore_target_hosts = <; 0.0.0.0 ; 127.0.0.0/8 ; ::1

smarthost2:
  driver = manualroute
  domains = ! +local_domains
  condition = ${if match_domain{${domain:$h_From:}}{domain.org}{yes}{no}}
  transport = remote_domain_org_smtp
  route_data = domain.org::587
  ignore_target_hosts = <; 0.0.0.0 ; 127.0.0.0/8 ; ::1


begin transports

remote_domain_com_smtp:
  driver = smtp
  message_size_limit = ${if > {$max_received_linelength}{998} {1}{0}}
  hosts_require_auth = domain.com
  headers_remove = received
  return_path = ${address:$h_from:}


remote_domain_org_smtp:
  driver = smtp
  message_size_limit = ${if > {$max_received_linelength}{998} {1}{0}}
  hosts_require_auth = domain.org
  return_path = ${address:$h_from:}
Run Code Online (Sandbox Code Playgroud)

其中domain.comdomain.org分别是我想要选择的域。