1

I'm trying to send an automated mailgun email from my flask app on Google App Engine. It works fine when I run locally. However, even though it runs without error the email is not being sent.

Here is the code:

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

Any thoughts?

Arkistarvh Kltzuonstev
  • 6,824
  • 7
  • 26
  • 56
pablowilks2
  • 299
  • 5
  • 15

1 Answers1

2

I am not familiar with the malign api, but looking at the example in the documentation, I think you forgot to add your domain to the 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()
Nazim Kerimbekov
  • 4,712
  • 8
  • 34
  • 58
Matthijs
  • 62
  • 5