【问题标题】:Mail Gun Email Not Working In Flask On Google App EngineMail Gun 电子邮件在 Google App Engine 上的 Flask 中不起作用
【发布时间】:2019-10-22 10:44:15
【问题描述】:

我正在尝试从 Google App Engine 上的烧瓶应用发送一封自动邮件枪电子邮件。当我在本地运行时它工作正常。但是,即使它运行没有错误,电子邮件也不会被发送。

代码如下:

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()

有什么想法吗?

【问题讨论】:

  • 您可以在日志中包含任何错误吗?

标签: python-3.x google-app-engine google-cloud-platform python-requests app-engine-flexible


【解决方案1】:

我对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()

【讨论】:

    猜你喜欢
    • 2016-07-31
    • 2018-08-02
    • 2011-02-04
    • 2016-06-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-24
    • 2010-10-27
    相关资源
    最近更新 更多