我怎样才能让后缀发送邮件到不同的中继主机?

我正在一台服务器上运行多个网站。 我正在使用sendgrid发送我的电子邮件。

现在,我有postfix中继所有传出邮件到一个单一的sendgrid帐户,使用smtp_sasl进行身份validation。

我需要能够发送每个域的电子邮件到不同的sendgrid帐户。 所以,对于domain1.com,我想要使用一个帐户转发到sendgrid,而对于domain2.com,我需要postfix使用不同的帐户进行身份validation。

如果没有一个正确的答案,这个问题会持续很久,这真是一个耻辱。 而对于这个问题,这是一个耻辱,它不是由sendgrid自己的文档处理。 所需的指令在http://www.postfix.org/SASL_README.html#client_sasl_sender处简洁处理,我将在这里引用一些sendgrid特定的修改:

/etc/postfix/main.cf: smtp_sender_dependent_authentication = yes sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd relayhost = my.default.relay.com /etc/postfix/sasl_passwd: # Per-sender authentication; see also /etc/postfix/sender_relay. @domain1.example.com username1:password1 @domain2.example.com username2:password2 # Login information for the default relayhost. [my.default.relay.com] username:password # Alternative form: # [mail.isp.example]:submission username:password /etc/postfix/sender_relay: # Per-sender provider; see also /etc/postfix/sasl_passwd. @domain1.example.com [sendgrid.net]:submission @domain2.example.com [sendgrid.net]:submission 

这里虽然有一些注意事项。

  1. 以上开关在SMTP信封发件人地址,而不是MIME标题。
  2. 获取postfix在MIME Header检查的基础上向不同方向发送邮件比较困难。 我敢肯定这是可能的,但后缀不是为此devise的。
  3. DKIM不关心来自SMTP地址或MIME来源发件人地址的SMTP信封是否与用于DKIM签名的域匹配。 这可能是一些接收服务器的垃圾邮件政策确实在意。 (更多信息非常感谢在这里)。
  4. 由于1和3,你很可能根本不需要发送到单独的sendgrid子帐户。

sender_dependent_relayhost_mapssender_dependent_default_transport_maps是你的朋友。