我正在尝试从Google App Engine上的烧瓶应用程序发送自动mailgun电子邮件。当我在本地运行时,它工作正常。但是,即使它没有错误运行,也不会发送电子邮件。
代码如下:
def send_simple_message(text):
url = 'https://api.mailgun.net/v3/{}/messages'.format('')
auth = ('api', '3822ba6d2b1ad202e83a4322a80c7600-87cdd773-683e02b1')
data = {
'from': 'Mailgun User <mailgun@{}>'.format('sandboxf04ggge3c1dc36e527c92f3a967e7f7c.mailgun.org'),
'to': 'example@gmail.com',
'subject': 'Simple Mailgun Example',
'text': text
}
response = requests.post(url, auth=auth, data=data)
response.raise_for_status()
有什么想法吗?
答案 0 :(得分:2)
我对malign api不熟悉,但是看文档中的示例,我认为您忘记将域添加到url:
def send_simple_message(text):
url = 'https://api.mailgun.net/v3/{}/messages'.format('sandboxf04ggge3c1dc36e527c92f3a967e7f7c.mailgun.org')
auth = ('api', '3822ba6d2b1ad202e83a4322a80c7600-87cdd773-683e02b1')
data = {
'from': 'Mailgun User <mailgun@{}>'.format('sandboxf04ggge3c1dc36e527c92f3a967e7f7c.mailgun.org'),
'to': 'example@gmail.com',
'subject': 'Simple Mailgun Example',
'text': text
}
response = requests.post(url, auth=auth, data=data)
response.raise_for_status()