如何配置后缀以将所有电子邮件丢弃到一个域并中继所有其他电子邮件?


9

我需要在开发/测试环境中设置后缀以过滤电子邮件,以便我们不会向客户发送垃圾邮件。在测试环境中,我们会清理所有用户数据,以便将电子邮件地址更改为@localhost,尽管出于测试目的,某些地址可能会在以后更改为有效的电子邮件地址。我们通过第三方提供商转发所有电子邮件,以进行传递,因此我要设置的后缀为:

  1. 丢弃发送给本地主机的所有电子邮件
  2. 将所有剩余的电子邮件转发给我们的第三方提供商。

对于postfix来说相对较新,最简单的方法是什么?

Answers:


8

好吧,我似乎已经设法通过一些搜索和测试来解决这个问题。这是我必须要做的:

  • 在/etc/postfix/main.cf中:

    transport_maps = hash:/etc/postfix/transport
    smtp_sasl_auth_enable = yes
    smtp_sasl_password_maps = static:<relayhost username>:<relayhost password>
    smtp_sasl_security_options = noanonymous
    smtp_tls_security_level = may
    start_tls = yes
    
  • 在/ etc / postfix / transport中:

    localhost discard: 
    localhost.localdomain discard:
    * relay:[smtp.relayhost.com]:587
    

中继显然也绕过了alias_maps指令,因此要使别名继续工作,我必须注释掉alias_maps和alias_database,并用virtual_alias_maps替换它们。virutal_alias_map的格式与alias_maps相同,因此很容易进行更改。

完成这些更改后,只需重新启动postfix并运行“ postmap / etc / postfix / transport”即可构建transport.db。现在,寻址到@localhost或@ localhost.localdomain的所有内容都将被丢弃,而其他所有内容都将通过指定的主机进行中继。


1
这不是OP的问题的答案,但是在相关说明中,这是我做的所有操作,将所有传出的邮件丢弃在产品框的临时克隆上:1.打开/etc/postfix/main.cf2.添加default_transport = discard:Outgoing email disabled on this node3.重新启动Postfix:service postfix restart* a reload可能就足够了
deoren
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.