【问题标题】:How to receive bounced mail using AWS SES With Postfix如何使用带有 Postfix 的 AWS SES 接收退回的邮件
【发布时间】:2014-08-02 12:01:48
【问题描述】:

我已按照他们的集成指南配置 postfix 以将邮件中继到 Amazon SES,并且发送电子邮件正常工作。

但是,我最近使用一个框架编写了一个 PHP 应用程序,该框架产生了格式错误的电子邮件。

SES 拒绝带有“554 Transaction failed: Expected MIME type, got =" 这是可以接受的电子邮件。

但是,我的本地 postfix 服务器随后尝试发送带有 from= 的发件人未送达通知,该通知被推送到中继地址。

SES 拒绝声明“501 Invalid MAIL FROM address provided (in reply to MAIL FROM command)”并且后缀从队列中删除退回邮件。

问题是,有什么更简单的方法可以确保我收到发送给我的原始 554 退回邮件?我没有看到让 SES 中继接受空字段的方法,所以我相信解决方案在于配置 postfix 以将退回消息直接传递给我。

请注意,我使用“退回邮件”一词可能不正确。邮件可能被拒绝,但我不确定这种情况的正确命名法。关键是 SES 中继不接受该消息,因此可以说它实际上并没有“走出门外”。

6 月 12 日 03:11:21 myserver postfix/smtp[6353]: 411BA21795: to=, relay=email-smtp.us-east-1.amazonaws.com[54.243.192.132]:25, delay=0.29, delays=0.05/0.02/0.15/0.07, dsn=5.0.0, status=bounced (主机 email-smtp.us-east-1.amazonaws.com[54.243 .192.132] 说: 554 交易失败: 预期MIME 类型,得到 =(回复 DATA 命令的结尾)) 6 月 12 日 03:11:21 myserver 后缀/清理 [6351]: 93F202179B: message-id= 6 月 12 日 03:11:21 myserver postfix/qmgr[895]: 93F202179B: from=, size=4673, nrcpt=1 (queue active) 6 月 12 日 03:11:21 myserver postfix/bounce [6354]:411BA21795:发件人未送达通知:93F202179B 6 月 12 日 03:11:21 myserver postfix/qmgr[895]: 411BA21795: 已移除 6 月 12 日 03:11:21 myserver postfix/smtp[6353]: 93F202179B: to=, relay=email-smtp.us-east-1.amazona ws.com[23.21.161.144]:25 , delay=0.17, delays=0.01/0/0.15/0, dsn=5.0.0, status=bounced (host email-smtp.us-east-1.amazonaws.com[23. 21.161.144] 说: 501 Invalid提供 MAIL FROM 地址(回复 MAIL FROM 命令)) 6 月 12 日 03:11:21 myserver postfix/qmgr[895]: 93F202179B: 已移除

【问题讨论】:

    标签: amazon-web-services smtp postfix-mta amazon-ses email-bounces


    【解决方案1】:

    为了接收绑定的消息,您必须设置一个信封发件人地址,该地址在您的 postfix 安装上本地发送。

    检查

       postconf mydestination
    

    查看哪些域在本地交付。 然后,您的应用程序需要将信封发件人地址设置为有效的本地交付地址。类似 root@name.of.your.machine

    【讨论】:

      【解决方案2】:

      如果您只需要将 Postfix 退回邮件发送到您的收件箱,只需设置下一个退回相关配置参数(/etc/postfix/main.cf 文件适用于 Ubuntu):

      # The list of error classes that are reported
      notify_classes = bounce, delay, policy, protocol, resource, software
      
      # The recipient of postmaster bounce notifications
      bounce_notice_recipient = bounceuser
      
      # The recipient of postmaster notifications about mail delivery problems that
      # are caused by policy, resource, software or protocol errors.
      error_notice_recipient = bounceuser
      
      # The recipient of postmaster notifications with the message headers of mail
      # that cannot be delivered within $delay_warning_time time units
      delay_notice_recipient = bounceuser
      

      bounceuser 是接收退回邮件的收件人。如果您需要将邮件转发给非本地收件人,只需编辑 /etc/aliases 以使 postfix 将邮件转发给您:

      # /dev/null will just delete the message from local
      bounceuser: /dev/null, <YOUR_EMAIL_ADDRESS_HERE>
      

      不要忘记重新创建别名数据库并重新启动后缀服务:

      sudo newaliases
      sudo service postfix restart
      

      ^_^

      【讨论】:

        【解决方案3】:

        您无法说服 postfix 使用 &lt;&gt; 以外的任何内容填写 MAIL FROM,因为它是 hardcoded

        您可以在 main.cf 中启用双弹跳通知:

        # enable double bounce notifications (resource, software are the defaults)
        notify_classes = 2bounce, resource, software
        
        # Set the sender address for 2bounce
        # @myhostname will be appended even if you have an @ in the sender
        double_bounce_sender = postmaster
        
        # Set the recipient address for 2bounce
        2bounce_notice_recipient = bounce.notify@company.com
        # (and resource, software)
        error_notice_recipient = bounce.notify@company.com
        

        你最终会得到这样的结果。

        PHP app (From: <your-app@company.com>) --> SES (To: <some-offiste@customer.com>) 
        : 5xx Rejected 
        
        Postfix (From: <>) -> SES (<your-app@company.com>)
        : 501 Rejected Invalid MAIL FROM
        
        Postfix (From: <postmaster@company.com>) -> SES (<bounce.notify@company.com>)
        

        虽然这严格回答了将通过 SES 尝试退回邮件的问题,但值得注意的是,在电子邮件由于配置问题而失败的情况下,这不一定比将退回收件人设置为更有用其他答案中建议的本地邮箱 - 2bounce 邮件会遇到相同的配置问题,并且可能也无法发送。

        【讨论】:

          猜你喜欢
          • 2020-10-19
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2017-01-30
          • 1970-01-01
          • 2017-12-30
          • 2012-05-25
          • 2019-09-01
          相关资源
          最近更新 更多