如果我尝试使用Boto 3发送带有Reply-To
标头的SES电子邮件,该标头与电子邮件中的其他标头不匹配,请使用如下脚本...
import boto3
client = boto3.client('ses')
client.send_email(
Destination={
'ToAddresses': [
"someone@example.com"
],
'ReplyToAddresses': [
"someoneelse@example.com"
]
},
Message={
'Body': {
'Text': {
'Charset': "UTF-8",
'Data': 'Bla bla bla',
},
},
'Subject': {
'Charset': "UTF-8",
'Data': 'Bla bla bla',
},
},
Source="My Company <noreply@example.com>",
)
...然后我收到这样的错误:
Traceback (most recent call last):
File "/Users/markamery/test.py", line 24, in <module>
Source="My Company <noreply@shielddx.com>",
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 320, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 596, in _make_api_call
api_params, operation_model, context=request_context)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/client.py", line 632, in _convert_to_request_dict
api_params, operation_model)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/botocore/validate.py", line 291, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError: Parameter validation failed:
Unknown parameter in Destination: "ReplyToAddresses", must be one of: ToAddresses, CcAddresses, BccAddresses
这对我来说没有多大意义。我在这里尝试做的事情似乎是一种最佳做法(请参见https://stackoverflow.com/a/14555043/1709587),根据https://forums.aws.amazon.com/thread.jspa?threadID=60093&tstart=0,从2011年开始,您可以在“回复至”中使用“任何电子邮件地址”标头。
什么原因导致此错误?自2011年该论坛发布以来,SES的规则是否再次更改?我上面看到的错误是对in the sandbox帐户(如我的帐户)的未记录限制吗?还是这是一个错误-客户端的Boto 3是否比AWS API本身对ReplyToAddresses
进行更严格的验证?
答案 0 :(得分:1)
根据boto3 docs,您需要将回复地址列表放在Destinations参数之外的参数中。我也觉得很奇怪。
send_mail(
...,
Destination={...},
ReplyToAddresses=[
'someoneelse@example.com',
])