Created
June 3, 2016 12:30
-
-
Save jehutymax/752665d992e7acab2f343142191f651d to your computer and use it in GitHub Desktop.
Send e-mails using Mailgun from a Python script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string | |
import requests | |
html = 'https://s3.amazonaws.com/.../email.htm' | |
content = requests.get(html) | |
DJANGO_MAILGUN_SERVER_NAME = '' | |
DJANGO_MAILGUN_API_KEY = '' | |
recipient_list = ['email@one.com', 'email@two.com'] | |
for email in recipient_list: | |
requests.post( | |
DJANGO_MAILGUN_SERVER_NAME + "/messages", | |
auth=("api", DJANGO_MAILGUN_API_KEY), | |
data={"from": "Us <us@email.com>", | |
"to": email, | |
"o:campaign": "", # optional, but it was cool (and creepy) to track opens and clicks. | |
"subject": "Your subject", | |
"text": 'Your alt text for non-html clients', | |
"html": content.text}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you so much for the code. 🫡🫡🫡🫡🫡🫡