Exim 4 除一个用户外,其他用户均路由至备用 smtp

Exim 4 除一个用户外,其他用户均路由至备用 smtp

我们正在将我们的邮件服务器从 EXIM 迁移出去,并且正在努力处理主机服务器上生成的电子邮件(例如 Web 表单和系统消息),因为它们无法传递到新主机。

我正在寻找一个路由脚本,该脚本基本上可以停止所有本地传送并将所有 @domain.com 电子邮件传送到我们的新服务器 hqmail.domain.com

然而有一个警告,如果它真的是 - 我们为这个服务器留下了一个功能,它由知道它的ip的嵌入式设备直接寻址,并且它使用服务器从[电子邮件保护][电子邮件保护] 该用户位于 mysql 数据库中,并且具有精心设计的跳出控制系统。

我看到我们的 vmail.user 数据库有路由和路由列,并尝试将它们设置为 1,hqmail.mydomain.com 认为逻辑在某处,但它似乎不存在。这本来会非常简单!

所以现在我正在浏览路由器目录中的 00_exim4-config 文件,坦率地说,完全不知道如何做到这一点。

通过浏览,我发现有很多方法可以做到这一点,对我来说,最简单的方法是使用我在 200_exim4-config_primary 文件中找到的路由/路由逻辑

  # Relay Router
  smart_route:
   driver = manualroute
   condition = ${if eq{}{${lookup mysql {SELECT id FROM users WHERE id='${sender_address}' AND routed=1 }}}{no}{yes}}
   transport = remote_smtp
   route_data = ${lookup mysql {SELECT route FROM users WHERE id='${sender_address}' AND routed=1 }}

这看起来像我想要的,但如果我设置 routed=1 并在路由字段中输入 hqmail.mydomain.com,它就不起作用。

我想知道它是否不起作用,因为这在文件中位于其上方:

dnslookup_relay_to_domains:
  debug_print = "R: dnslookup_relay_to_domains for $local_part@$domain"
  driver = dnslookup
  errors_to = bounce_control
  condition = ${if eq{}{${lookup mysql {SELECT id FROM users WHERE id='${sender_address}' }}}{no}{yes}}
  domains = ! +local_domains : +relay_to_domains
  transport = remote_smtp
  same_domain_copy_routing = yes
  no_more

任何帮助,将不胜感激!

以下是完整的 200_exim-4_primary 文件:

### router/200_exim4-config_primary
#################################
# This file holds the primary router, responsible for nonlocal mails

.ifdef DCconfig_internet
# configtype=internet
#
# deliver mail to the recipient if recipient domain is a domain we
# relay for. We do not ignore any target hosts here since delivering to
# a site local or even a link local address might be wanted here, and if
# such an address has found its way into the MX record of such a domain,
# the local admin is probably in a place where that broken MX record
# could be fixed.

dnslookup_relay_to_domains:
  debug_print = "R: dnslookup_relay_to_domains for $local_part@$domain"
  driver = dnslookup
  errors_to = bounce_control
  condition = ${if eq{}{${lookup mysql {SELECT id FROM users WHERE id='${sender_address}' }}}{no}{yes}}
  domains = ! +local_domains : +relay_to_domains
  transport = remote_smtp
  same_domain_copy_routing = yes
  no_more




#mysql_autorespond:
#    driver = accept
#    no_verify
#    no_expn
#    debug_print = "auto responder lookup for  $local_part@$domain"
#    senders = "! ^.*-request@.*:\
#               ! ^owner-.*@.*:\
#               ! ^root@.*:\
#               ! ^postmaster@.*:\
#               ! ^listmaster@.*:\
#               ! ^mailer-daemon@.*"
#    condition = ${if eq{} {${lookup mysql{SELECT activ FROM responder WHERE \
#                ((username='$local_part' AND domain='$domain') OR (username='$local_part_prefix' AND domain='$local_part_suffix')) \
#                AND (sender ='$sender_address' or sender ='$reply_address' or sender ='*') \
#                AND activ='YES' AND valid_from <= now() AND valid_to >= now() ORDER BY sender DESC LIMIT 1 }}}{NO}{YES}}
#    unseen
#    transport = autorespond_mysql



# deliver mail directly to the recipient. This router is only reached
# for domains that we do not relay for. Since we most probably can't
# have broken MX records pointing to site local or link local IP
# addresses fixed, we ignore target hosts pointing to these addresses.

# Relay Router
  smart_route:
   driver = manualroute
   condition = ${if eq{}{${lookup mysql {SELECT id FROM users WHERE id='${sender_address}' AND routed=1 }}}{no}{yes}}
   transport = remote_smtp
   route_data = ${lookup mysql {SELECT route FROM users WHERE id='${sender_address}' AND routed=1 }}



dnslookup:
  debug_print = "R: dnslookup for $local_part@$domain"
  driver = dnslookup
  condition = ${if eq{}{${lookup mysql {SELECT id FROM users WHERE id='${sender_address}' }}}{no}{yes}}
  #errors_to = bounce_control
  domains = ! +local_domains
  transport = remote_smtp
  same_domain_copy_routing = yes
  # ignore private rfc1918 and APIPA addresses
  ignore_target_hosts = 0.0.0.0 : 127.0.0.0/8 : 192.168.0.0/16 :\
                        172.16.0.0/12 : 10.0.0.0/8 : 169.254.0.0/16 :\
            255.255.255.255
  no_more


#denied_lookup:
#  debug_print = "R: DENIED"
#  driver = redirect
#  transport = bounce_control_pipe
#  no_more

.endif


.ifdef DCconfig_local
# configtype=local
#
# Stand-alone system, so generate an error for mail to a non-local domain
nonlocal:
  debug_print = "R: nonlocal for $local_part@$domain"
  driver = error
  domains = ! +local_domains
  allow_fail
  data = :fail: Mailing to remote domains not supported
  no_more

.endif


.ifdef DCconfig_smarthost DCconfig_satellite
# configtype=smarthost or configtype=satellite
#
# Send all non-local mail to a single other machine (smarthost).
#
# This means _ALL_ non-local mail goes to the smarthost. This will most
# probably not do what you want for domains that are listed in
# relay_domains. The most typical use for relay_domains is to control
# relaying for incoming e-mail on secondary MX hosts. In that case,
# it doesn't make sense to send the mail to the smarthost since the
# smarthost will probably send the message right back here, causing a
# loop.
#
# If you want to use a smarthost while being secondary MX for some
# domains, you'll need to copy the dnslookup_relay_to_domains router
# here so that mail to relay_domains is handled separately.

smarthost:
  debug_print = "R: smarthost for $local_part@$domain"
  driver = manualroute
  domains = ! +local_domains
  transport = remote_smtp_smarthost
  route_list = * DCsmarthost byname
  host_find_failed = defer
  same_domain_copy_routing = yes
  no_more

.endif


# The "no_more" above means that all later routers are for
# domains in the local_domains list, i.e. just like Exim 3 directors.

答案1

应该有两个;不多也不少:

begin routers

alerts:
   driver = accept
   condition = ${if eq{$local_part@$domain}{'[email protected]'}{yes}{no}}
   condition = ${if eq{$sender_address}{'[email protected]'}{yes}{no}}
   transport = remote_smtp

migrator:
   driver = manualroute
   condition = ${if eq{$domain}{'domain.com'}{yes}{no}}
   transport = remote_smtp
   route_data = hqmail.domain.com
   cannot_route_message = User unknown

# end routers

我希望这会有所帮助。

相关内容