我想Mandrill
Google App Engine
使用Python
,urlfetch
,我可以使用Google提供的#The jMessage below was split with the formatting below to make it easier to follow
模块
使用的代码I' m的改编如下:
#the real code doesn't have such indentation issues
jMessage =
{
"key": mailchimp_key,
"message":
{
"track_clicks": False,
"track_opens": True,
"tags": [],
"google_analytics_domains": [],
"html": message_html,
"subject": "Reset your password",
"from_name": None,
"merge_var_map": {},
"auto_text": False,
"from_email": from_email,
"headers": {},
"google_analytics_campaign": [],
"merge_vars": [],
"text": None,
"global_merge_vars": [],
"url_strip_qs":False,
"to":
[
{
"email": to_email,
"name": None
}
]
}
}
headers = {'content-type': 'application/json'}
result = urlfetch.fetch(url='https://mandrillapp.com/api/1.0/messages/send.json',\
headers=headers, payload=json.dumps(jMessage), method=urlfetch.POST)
print result.content
{"status":"error","code":-2,"name":"ValidationError","message":"Validation error{\"message\":\"Please enter an array\"}"}
输出结果如下:
jMessage
它想要的阵列究竟是什么?我不确定该怎么做,所以我把#34;消息"密钥,来自[]
和[]
,使其成为一个列表。实际上,它停止了抱怨数组,但输出只是{{1}},我没有收到任何电子邮件。