7

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

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

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

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

SES 拒绝声明“提供了 501 无效的 MAIL FROM 地址(作为对 MAIL FROM 命令的回复)”,并且 postfix 从队列中删除了退回邮件。

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

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

6 月 12 日 03:11:21 myserver postfix/smtp[6353]: 411BA21795: to=<valid@validdomain.com>, 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=<valid@validdomain.com>, 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: 已移除
4

3 回答 3

1

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

# 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>

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

sudo newaliases
sudo service postfix restart

^_^

于 2017-06-14T16:07:45.850 回答
0

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

查看

   postconf mydestination

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

于 2016-12-29T13:42:38.823 回答
0

您无法说服 postfix 用其他任何内容填写 MAIL FROM,<>因为它是硬编码的。

您可以做的是在 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 邮件将受到相同的配置问题的影响,并且可能也无法发送。

于 2021-11-19T03:12:23.440 回答