如何获得后缀以将邮件发送到其他中继主机?


10

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

现在,我使用smtp_sasl进行身份验证,将所有后发邮件中继到单个sendgrid帐户的postfix。

我需要能够将每个域的电子邮件发送到不同的sendgrid帐户。因此,对于domain1.com,我想使用一个帐户中继到sendgrid,对于domain2.com,我需要后缀以使用其他帐户进行身份验证。



我不这么认为-他们需要转到同一台主机,但使用不同的身份验证。
Joe Van Dyk

Answers:


10

可惜的是,这个问题持续了这么长时间却没有正确的答案。因此,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. 要获得基于MIME标头检查的后缀以不同方向发送邮件的难度更大。我敢肯定这是有可能的,但是后缀不是为此设计的。
  3. DKIM不在乎SMTP信封来自地址还是MIME标头来自地址是否与DKIM签名所使用的域匹配。某些接收服务器的垃圾邮件策略可能确实有用。(更多信息在这里非常感谢)。
  4. 由于1.和3.,您完全有可能根本不需要发送到单独的sendgrid子帐户。

我过去几年一直在做的事情非常有效!
Joe Van Dyk 2013年

1
@JoeVanDyk您在问题两年后发表了该评论,并说您已经这样做了两年。
barlop

发布问题后不久,我找到了答案..却忘了回来更新。
Joe Van Dyk

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.