为什么 Amazon SES 邮件模拟器退回不起作用? (我是不是漏掉了 headers 之类的东西?)
Why is Amazon SES mail simulator bounces not working? (Am I missing headers or something?)
我正在尝试使用此处记录的亚马逊 SES 模拟器:http://docs.aws.amazon.com/ses/latest/DeveloperGuide/mailbox-simulator.html
消息的 body 如下所示:
MIME-Version: 1.0
Content-Type: multipart/alternative; charset="utf-8";
boundary="===============123456789=="
Content-Transfer-Encoding: base64
Subject: hello test message!
Reply-To: my_address@my_provider.com
To: complaint@simulator.amazonses.com
Return-Path: my_address@my_provider.com
Bounces-to: my_address@my_provider.com
Errors-to: my_address@my_provider.com
From: my_address@my_provider.com
--===============123456789==
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Ym9keSB3aXRoIG5vbmNlOiAw
--===============123456789==
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
Ym9keSB3aXRoIG5vbmNlOiAw
--===============123456789==--
我将此作为 body 发送,并使用 boto3 接口 ses_client.send_raw_message
。
我正在生成此消息 body,内容类似于此
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import re
msg = MIMEMultipart('alternative')
msg.set_charset('utf8')
text_message='Ym9keSB3aXRoIG5vbmNlOiAw'
p = re.compile('<.*?>')
text_message = 'body with nonce: {}'.format(str(nonce))
text = MIMEText(p.sub('', text_message), 'plain', 'utf8')
html = MIMEText(text_message, 'html', 'utf8')
msg.attach(text)
msg.attach(html)
source = 'my_email@my_provider.com'
msg['Subject'] = 'hello test message!'
msg['Reply-To'] = source
msg['To'] = to_mail
msg['Return-Path'] = source
msg['Bounces-to'] = source
msg['Errors-to'] = source
所以我可以通过 SES 发送电子邮件,而且效果很好。
我还可以向 complaint@simulator.amazonses.com
发送电子邮件,这很有效。
我没有设置任何 SNS 消息传递,但我希望通过我设置的所有 header 字段,在所需地址获得反弹。但是,如果我使用 bounce@simulator.amazonses.com
.
什么也不会发生
这是亚马逊承认的 header 字段列表:
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/header-fields.html
我还启用了电子邮件反馈转发功能,如下所述:
http://docs.aws.amazon.com/ses/latest/DeveloperGuide/notifications-via-email.html
此外,我使用以下逻辑发送电子邮件:
amazon_client = boto3.client('ses', 'region', **credentials)
amazon_client.send_raw_email(
Source=from_mail,
Destinations=to_mails,
RawMessage={'Data': body}
)
根据记录如何接收通知的页面,我应该在指定的 Source
地址取回邮件——这是我设置的,而且我确实为...启用了电子邮件反馈转发。
有什么我可能遗漏的想法吗?
您输入的 headers 表明真正的问题是错误的期望。 Errors-To:
几乎会被您能找到的所有内容忽略,并且 Return-Path:
将被 receiving MTA 替换为信封发件人。要控制退回,您需要控制信封发件人(传统上使用 sendmail -f
),而您在 headers 中放入的内容完全无关。
已解决。
退回地址与 'From' 地址不同。因此,退回邮件最终进入了该其他地址的垃圾邮件。
有趣的是,该地址有一个过滤器,可以将所有内容转发到我在发送电子邮件时用作 'From' 地址的地址。
所以我的困惑是因为我希望从另一个地址转发邮件,但退回的邮件从未被转发。
我正在尝试使用此处记录的亚马逊 SES 模拟器:http://docs.aws.amazon.com/ses/latest/DeveloperGuide/mailbox-simulator.html
消息的 body 如下所示:
MIME-Version: 1.0
Content-Type: multipart/alternative; charset="utf-8";
boundary="===============123456789=="
Content-Transfer-Encoding: base64
Subject: hello test message!
Reply-To: my_address@my_provider.com
To: complaint@simulator.amazonses.com
Return-Path: my_address@my_provider.com
Bounces-to: my_address@my_provider.com
Errors-to: my_address@my_provider.com
From: my_address@my_provider.com
--===============123456789==
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: base64
Ym9keSB3aXRoIG5vbmNlOiAw
--===============123456789==
MIME-Version: 1.0
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64
Ym9keSB3aXRoIG5vbmNlOiAw
--===============123456789==--
我将此作为 body 发送,并使用 boto3 接口 ses_client.send_raw_message
。
我正在生成此消息 body,内容类似于此
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
import re
msg = MIMEMultipart('alternative')
msg.set_charset('utf8')
text_message='Ym9keSB3aXRoIG5vbmNlOiAw'
p = re.compile('<.*?>')
text_message = 'body with nonce: {}'.format(str(nonce))
text = MIMEText(p.sub('', text_message), 'plain', 'utf8')
html = MIMEText(text_message, 'html', 'utf8')
msg.attach(text)
msg.attach(html)
source = 'my_email@my_provider.com'
msg['Subject'] = 'hello test message!'
msg['Reply-To'] = source
msg['To'] = to_mail
msg['Return-Path'] = source
msg['Bounces-to'] = source
msg['Errors-to'] = source
所以我可以通过 SES 发送电子邮件,而且效果很好。
我还可以向 complaint@simulator.amazonses.com
发送电子邮件,这很有效。
我没有设置任何 SNS 消息传递,但我希望通过我设置的所有 header 字段,在所需地址获得反弹。但是,如果我使用 bounce@simulator.amazonses.com
.
这是亚马逊承认的 header 字段列表: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/header-fields.html
我还启用了电子邮件反馈转发功能,如下所述: http://docs.aws.amazon.com/ses/latest/DeveloperGuide/notifications-via-email.html
此外,我使用以下逻辑发送电子邮件:
amazon_client = boto3.client('ses', 'region', **credentials)
amazon_client.send_raw_email(
Source=from_mail,
Destinations=to_mails,
RawMessage={'Data': body}
)
根据记录如何接收通知的页面,我应该在指定的 Source
地址取回邮件——这是我设置的,而且我确实为...启用了电子邮件反馈转发。
有什么我可能遗漏的想法吗?
您输入的 headers 表明真正的问题是错误的期望。 Errors-To:
几乎会被您能找到的所有内容忽略,并且 Return-Path:
将被 receiving MTA 替换为信封发件人。要控制退回,您需要控制信封发件人(传统上使用 sendmail -f
),而您在 headers 中放入的内容完全无关。
已解决。
退回地址与 'From' 地址不同。因此,退回邮件最终进入了该其他地址的垃圾邮件。 有趣的是,该地址有一个过滤器,可以将所有内容转发到我在发送电子邮件时用作 'From' 地址的地址。
所以我的困惑是因为我希望从另一个地址转发邮件,但退回的邮件从未被转发。