postfix smtp_fallback_relay延期邮件到单个域

我使用Postfix将邮件发送到我的组织外的邮件服务器,邮件服务器经常拒绝/推迟我的邮件。 我的Postfix服务器看到这些消息被延期,并再次尝试,最终通过。 最终交货可能需要一个小时,这使我的用户不满。 相比之下,从我的Postfix服务器到其他主机的邮件正常工作。

我现在已经发现了关于这个域的第二个非正式的MX,它拒绝/推迟邮件。 在为域执行DNS MX查询时,不会出现第二个MX。 因此,对于问题域,我想使用第二个MX作为后备。 那就是:每当邮件被主MX推迟时,再次尝试非官方的第二个MX。

我看到已经有一个后缀configuration“smtp_fallback_relay”。 但是,文档似乎表明,我不能将回退的使用限制在单个域中。 该文档也没有提到延迟的消息处理。

那么有没有办法在Postfix中configuration一个单域的延期重试回退主机?

作为参考,我包括我的postconf输出(主机名和IP地址是假的):

alias_database = hash:/etc/aliases alias_maps = hash:/etc/aliases, hash:/etc/postfix/legacy_mailman, ldap:/etc/postfix/ldap-aliases.cf append_dot_mydomain = no biff = no config_directory = /etc/postfix default_destination_concurrency_limit = 2 inet_interfaces = all inet_protocols = all local_destination_concurrency_limit = 2 local_recipient_maps = $alias_maps mailbox_size_limit = 0 mydestination = myhost.my.network, localhost.my.network, localhost, my.network myhostname = myhost.my.network mynetworks = 127.0.0.0/8, [::ffff:127.0.0.0]/104, [::1]/128, 10.10.10.0/24 myorigin = my.network readme_directory = no recipient_delimiter = + relay_domains = $mydestination relayhost = smtp_fallback_relay = the.problem.host smtp_header_checks = smtpd_banner = $myhostname ESMTP $mail_name virtual_alias_maps = hash:/etc/postfix/virtual 

smtp_fallback_relay不处理延期的消息; 当主要目的地不可用时将立即尝试。
这通常是你想要的 – 正如设置所表明的那样,这是中继邮件的后备

我build议你调查为什么这个邮件服务器拒绝你的消息。

也就是说,有几种方法可以解决这个问题。
第一个也是最简单的解决scheme就是在本地伪造这个MX,这样postfix就可以在正常交付时包含这个MX。
要实现这一点,请将smtp_host_lookup设置smtp_host_lookup ; 这将查询您的/ etc / hosts文件以及DNS(通过本地系统parsing器,或者更具体地,通过在nsswitch.conf中configuration的任何内容)。

你也可以安装类似dnsmasq的东西,以允许你覆盖或添加特定的DNS条目到现有的域; 如果两个relay都有MXlogging,这是唯一的基于DNS的解决scheme,因为/ etc / hosts只支持Alogging。

后缀解决scheme涉及到一些查找技巧,这只有在使用SQL映射时才有可能:

您必须添加一个transport_maps条目,其中包含一个可以基于带外操作返回替代结果的查找; 例如,对MX可用性的定期检查(通过cron等)可以replace改变该特定域的下一跳的正则表查找表; 后缀将立即获取对这些表的更改。

所以这里是我在Ubuntu Lucid上使用的configuration:

  • apt-get install dnsmaq
  • /etc/dnsmasq.d中添加文件problem_domain_mx_override.conf

     mx-host=problem.domain,existing-mx.problem.domain,25 mx-host=problem.domain,backdoor-mx.problem.domain,10 
    • 后门的价值较低,因此将首先尝试,但如果后门消失,则会回落到标准mx
  • /etc/init.d/dnsmasq restart
  • /etc/resolv.conf

     search my.domain nameserver 127.0.0.1 nameserver 8.8.8.8 # "normal" name servers 
  • /etc/init.d/postfix restart
    • 似乎后缀重新加载不足以接受DNS欺骗