postfix 中一次查询多个 maps 需要注意的地方

今天遇到的一个情况,需要配置 postfix 完成下列功能:

  1. 对于特定域名的收件人地址,把信发给特定的服务器
  2. 其它的随机选择出口 IP 往外发送

这两个功能分别都很容易实现:

第一个用 transport_maps 的域后缀匹配功能

example.com smtp:chsMX.example.com

第二个在 main.cf 里创建多个指定 IP 地址的 smtp 出口,然后在 transport_maps 里查询一个 tcp 类型的外部服务,在该外部服务里用随机算法选择出口

但是,两个一起用的时候会出现问题。因为 postfix 会先拿完整的邮件地址去依次查询两个 maps ,第一个匹配不上,然后匹配第二个,成功后直接返回了,导致特殊的邮件域路由功能失效。解决方法是把第一个改为 pcre 或者 regexp 格式的查询表:

/[email protected]/ smtp:chsMX.example.com

这样就可以确保需要特殊处理的邮件域匹配在第一个查询表上,而不会去查询第二个查询表。

This entry was posted in 默认分类 and tagged , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.