我遇到一个奇怪的问题。
此代码看起来不错,但是每次都返回“模板数据无效”。
我做错什么了吗?
可能是错误吗?
谢谢
-
MacOS,最新版本。
Python 3.6.6
boto3 == 1.9.57
import boto3
verified_email='theemail@examplemail.com'
template_name = "TestTemplateDeleteMe"
template = {
"TemplateName": template_name,
"SubjectPart": "Test send bulk template email",
"HtmlPart": "<h1>Hello {{name}},</h1>Favorite animal is {{favorite_animal}}.",
"TextPart": "Dear {{name}},\r\nYour favorite animal is {{favorite_animal}}."
}
client = boto3.client('ses', region_name='eu-west-1')
try:
client.create_template(Template=template)
except Exception as e:
print(str(e))
try:
if e.response['Error']['Code'] != 'AlreadyExists':
raise e
except KeyError:
raise e
response = client.send_bulk_templated_email(
Source=verified_email,
Template='TestTemplateDeleteMe',
Destinations=[{'Destination': {'ToAddresses': [verified_email]}}],
DefaultTemplateData='{"name": "TestEmailPerson", "favorite_animal": "TestEmailAnimal"}'
)
print(response)