大网数据广告活动
服务器运维问答

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

· 52CE 我爱测

I want to route emails with the From: .*@host1.com through smtp.server1.com and emails with the From: .*@host2.com through smtp.server2.com . For the moment, I have smarthost configured with dpkg-reconfigure exim4-config so that …

问题原文

原帖链接 · mikhailian · CC BY-SA 3.0

I want to route emails with the From: .*@host1.com through smtp.server1.com and emails with the From: .*@host2.com through smtp.server2.com.

For the moment, I have smarthost configured with dpkg-reconfigure exim4-config so that update-exim4.conf.conf contains the line dc_smarthost='smtp.server1.com::587'. That is, everything routes through smtp.server1.com.

I tried adding another router just before the definition of smarthost: in the config file, setting 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

but exim still routes everyting via smtp.server1.com. Do I use the senders condition correctly?

AFAIU, this should be a rather common setup for cases when people with emails .@google.com and .@gmail.com do not want to reveal in their @gmail.com email headers the fact that they are also google employees, so the routhing should be different.

已采纳解答

原帖链接 · mikhailian · CC BY-SA 4.0

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

The following works:

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

where domain.com and domain.org are respectively the domains I want to choose between.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-08)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。