0

I want to test my Python program which uses the Mailgun API. When executing the program, I did not get any Terminal output. However, on my Mailgun dashboard I do not see that any email was sent and I did not get an email to the specified email as well.

import requests

def send_simple_message():
    return requests.post(
        "https://api.mailgun.net/v3/sandbox***.mailgun.org/messages",  #replaced the actual link
        auth=("api", "key"), #replaced the actual API key with "key"
        data={"from": "User <test@gmail.com>", #replaced mail
              "to": ["User", "Test@gmail.com"], #replaced mail
              "subject": "Hello",
              "text": "Testing some Mailgun awesomness!"})

send_simple_message()

Thank you for your help!

  • you didn't not get any terminal output, because you never asked for it. You just returned from your function without checking if anything went wrong – dgan Mar 25 '20 at 19:54
  • Can you let us know of the result that is returned from the function? – Ciaran Gallagher Mar 26 '20 at 10:13
  • Now I get ` { "message": "Sandbox subdomains are for test purposes only. Please add your own domain or add the address to authorized recipients in Account Settings." }`. However, I have already added the email address to the trusted recipients and it is still showing the error – Python-Data-Science-Learner Mar 26 '20 at 10:20
  • You should use your own domain (not the sandbox). This detailed description may help you: https://stackoverflow.com/questions/68150905/can-i-send-email-with-mailgun-sandbox-domain-under-my-local-os/68542876#68542876 – FredyWenger Jul 27 '21 at 11:18

0 Answers0