Skip to content

Instantly share code, notes, and snippets.

@fdcore
Created September 30, 2016 09:18
Show Gist options
  • Save fdcore/bf0bee9aa573d4263f2eabe22cd84369 to your computer and use it in GitHub Desktop.
Save fdcore/bf0bee9aa573d4263f2eabe22cd84369 to your computer and use it in GitHub Desktop.
Send mail via Mailgun by requests on Python
import requests
def mailgun_sendmail(title='no title', content='', recipients=[]):
status = requests.post("https://api.mailgun.net/v3/DOMAIN/messages", # DOMAIN - your domain from mailgun
auth=("api", "key-2h2f...."), # YOR KEY with key-
data={"from": "postmaster@DOMAIN", # YOUR mail from mailgun
"to": recipients,
"subject": title,
"html": content
})
return status.status_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment