指定通过exim4用于邮件的远程端口

时间:2020-03-06 14:56:37  来源:igfitidea点击:

我有一个使用Exim4的库存Debian Etch系统。这些域大多是本地域,但有些是远程域。为了处理远程邮件的传递,我使用Debian配置文件:

/etc/exim4/hubbed_hosts

该文件列出了域名和要传递给的远程MX计算机。例如:

example.org:  mx.example.com
  example.com:  mx2.example.com

查看exim4配置文件,我发现它的用法如下:

hubbed_hosts:
  debug_print = "R: hubbed_hosts for $domain"
  driver = manualroute
  domains = "${if exists{CONFDIR/hubbed_hosts}\
                   {partial-lsearch;CONFDIR/hubbed_hosts}\
              fail}"
  route_data = ${lookup{$domain}partial-lsearch{CONFDIR/hubbed_hosts}}
  transport = remote_smtp

我遇到的问题是,我正在使用的某些主机需要将其邮件传递到非标准端口。不幸的是,如果我尝试将其更改为包含端口,那么Debian的hubbed_hosts文件将无法工作:

example.org: mx1.example.org:2525
example.com: 1.2.3.4.2525

是否可以动态允许指定端口?

解决方案

进行指定端口的新传输

remote_hub_2525:
driver = smtp
port = 2525

然后为需要非标准交付的域创建路由器

non_standard_hub:
driver = manualroute
domains = example.org : example.com
transport = remote_hub_2525
no_more

我希望有一些动态的东西,这个解决方案有效:

port = ${if exists{/etc/exim4/ports.list}\
              {${lookup{$domain}lsearch{/etc/exim4/ports.list}\
              {$value}{25}}}{25}}

然后,一个简单的文件可能会在每个域中包含端口列表:

example.org: 2525
   example.com: 26

我们可能可以使用$ {extract}运算符来组合端口号和主机名,就像原始问题中的示例一样。

像(未经测试的)之类的东西:

route_data = ${extract{1}{:}{${lookup{$domain}partial-lsearch{CONFDIR/hubbed_hosts}}}}

默认情况下实际上支持此功能,而无需对exim4配置进行任何更改。

在hubbed_hosts中,用冒号分隔主机,并用双冒号指定端口号。
前任:

domain1: server1:server2::port:server3
domain2: server1::port
domain3: server1:server2

有关更多信息,请访问http://www.exim.org/exim-html-current/doc/html/spec_html/ch20.html#SECID122