amazon-web-services - 如何使用带有 Postfix 的 AWS SES 接收退回的邮件

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

我已经按照他们的集成指南将 postfix 配置为将邮件中继到 Amazon SES,并且发送电子邮件没有问题。

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

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

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

SES 拒绝说明“501 提供的邮件发件人地址无效(回复邮件发件人命令))”并且后缀从队列中删除退回邮件。

问题是,确保收到发送给我的原始 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 (host email-smtp.us-east-1.amazonaws.com[54.243 .192.132] 说: 554 Transaction failed: Expected MIME 类型,得到 =(回复 DATA 命令的结尾))
6 月 12 日 03:11:21 myserver postfix/cleanup[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无效提供的 MAIL FROM 地址(回复 MAIL FROM 命令))
6 月 12 日 03:11:21 myserver postfix/qmgr[895]:93F202179B:已删除

最佳答案

如果您只需要将 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

退回用户是将收到退回相关邮件的收件人。如果您需要将消息转发给非本地收件人,只需编辑/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

^_^

关于amazon-web-services - 如何使用带有 Postfix 的 AWS SES 接收退回的邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24179706/

相关文章:

linux - postfix 对收到的邮件执行命令,找不到配置

php - 通过php为存储在mysql中的postfix电子邮件用户设置密码

amazon-web-services - 不支持文档架构版本 2.2

c# - 系统.Net.Mail.SmtpException : The SMTP server requires a secure connection or the client was not authenticated

mysql - rake db :migrate - Rake aborted! 访问被拒绝

ruby - 使用最大行长度简洁地序列化 JSON

python - Django send_mail 通过 gmail 很慢

python - 将 postfix 邮件集成到我的(python)webapp

java - 无法创建 PoolableConnectionFactory (未知数据库 'XYZ_DEV' )

java - 用户: arn:aws:sts::{account_id}:assumed-role/* 无权对资源执行: sts:AssumeRole: arn:aws:iam::{account_id}:role/*