AWS SES:Postfix 中继出现“电子邮件地址未验证”错误

Rus*_*l G 4 postfix amazon-ec2 amazon-web-services amazon-ses

我已经设置了 Amazon SES,验证了我的域,并已获准使用生产模式。当来自外部世界的电子邮件发送到我域中的地址时,我的服务器将其转发回 Gmail 帐户,但转发被 Amazon SES 拒绝并显示错误

Email address is not verified
Run Code Online (Sandbox Code Playgroud)

例如,如果来自 yahoo.com 的某人通过“me@mydomain.com”向我发送电子邮件,然后该电子邮件由于 /etc/aliases 中的条目而立即转发到“me@gmail.com”,则 SES 是拒绝向 gmail.com 发送电子邮件,即使“mydomain.com”是经过验证的域。当我在 Postfix 中打开详细登录以连接到 gmail.com 时,该电子邮件似乎来自 yahoo.com 并转到 gmail.com —— 这两个都不是我的域。它是在抱怨电子邮件最初来自 yahoo.com 吗?如果是这种情况,那么在将邮件从外部域通过我的域中继到另一个 (gmail) 域时,我是否无法使用 SES?

但是,如果我发送来自我的域的电子邮件并转到 gmail 地址,它可以正常工作。

这是/var/log/maillogSES 服务器拒绝转发到 gmail.com 的行:

Apr 15 02:11:43 ip-10-194-190-140 postfix/smtp10191: 9013922528: to=<myaddress@gmail.com>, orig_to=<myaddress@mydomain.com>, relay=email-smtp.us-east-1.amazonaws.comhttp://54.243.71.143:25, delay=0.32, delays=0.01/0/0.11/0.2, dsn=5.0.0, status=bounced (host email-smtp.us-east-1.amazonaws.comhttp://54.243.71.143 said: 554 Message rejected: Email address is not verified. (in reply to end of DATA command))`
Run Code Online (Sandbox Code Playgroud)

这是我添加到 /etc/postfix/main.cf 的行:

relayhost = email-smtp.us-east-1.amazonaws.com:25
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_use_tls = yes
smtp_tls_security_level = encrypt
smtp_tls_note_starttls_offer = yes
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
Run Code Online (Sandbox Code Playgroud)

后续问题:

当这个问题发生时,电子邮件最终会去哪里?我的 Postfix 服务器正在接受“me@mydomain.com”的电子邮件,但 Amazon SES 拒绝转发到 gmail.com。但是电子邮件不在我服务器上的外发邮件队列中,也不在我服务器上帐户的邮箱中,也没有退回给原始发件人(在雅虎,在我上面的示例中)。它去了哪里?

mas*_*oeh 7

为什么 Amazon SES 在发送电子邮件时会抛出该错误?

例如,您已验证您的域 example.com。现在,someone@yahoo.commyaccount@example.com发送电子邮件。Postfix 很乐意接受它,并且由于别名文件,postfix 会将其转发到otheraccount@gmail.com

问题是,postfix在 SMTP 事务中使用了someone@yahoo.com作为信封发件人。这是 postfix 的理想和默认行为。目的是在 GMAIL 收到来自someone@yahoo.com 的电子邮件时不丢失发件人信息。不幸的是,Amazon SES 只允许作为example.com 的信封发件人域。

解决方案

从OP 在评论中提到的线程中,有一些解决方案可以更改信封发件人,使其通过 Amazon SES 限制。一种可能的解决方案是使用sender_canonical_maps。默认情况下,postfix 将重写信封和标题中的发件人。正确配置sender_canonical_classes 后,postfix 只会重写信封。

/etc/postfix/main.cf,添加

sender_canonical_maps = regexp:/etc/postfix/sender_canonical
sender_canonical_classes = envelope_sender
Run Code Online (Sandbox Code Playgroud)

/etc/postfix/sender_canonical,添加

/.*/    mysenderaddress@example.com
Run Code Online (Sandbox Code Playgroud)

问题是您的原始发件人未知。根据 Postfix 作者的建议,获取原始文件的一种方法是使用 check_sender_access 的前置操作

/etc/postfix/main.cf,添加

smtpd_data_restrictions = check_sender_access pcre:/etc/postfix/sender_access
Run Code Online (Sandbox Code Playgroud)

/etc/postfix/sender_access,添加

/(.*)/  prepend X-Envelope-From: <$1>
Run Code Online (Sandbox Code Playgroud)

这些设置将添加X-Envelope-From包含原始发件人电子邮件地址的标题。

当这个问题发生时,电子邮件最终会去哪里?它去了哪里?

默认情况下,postfix 会将此邮件退回给原始发件人(雅虎地址)。拒绝后可以通过mail.log追踪。当然,一些后缀设置可以抑制退回邮件,或者雅虎可能会默默地拒绝它。