Last active
May 21, 2018 17:18
-
-
Save masiamj/1e497d900fdfb70795ffd828775edea9 to your computer and use it in GitHub Desktop.
Example Python code for Mike
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 sys | |
import requests | |
"""Define Constants""" | |
MAILGUN_DOMAIN = "" | |
MAILGUN_API_KEY = "" | |
''' | |
Entry point for the application | |
''' | |
def main(): | |
email_recipients = ["test@email.com"] | |
try: | |
response = send_simple_message("This is the subject", "This is the body", email_recipients) | |
response.raise_for_status() | |
print(f"Sent summary email successfully to {', '.join(email_recipients)}") | |
except requests.exceptions.HTTPError as error: | |
return "Error Running Script: " + str(error) | |
finally: | |
print("Done Running Script!") | |
''' | |
Sends an email via Mailgun | |
param {string} subject - Subject of the email | |
param {string} text - Body of the email | |
param {List<string>} to - List of emails | |
''' | |
def send_simple_message(subject, text, to): | |
return requests.post( | |
f"https://api.mailgun.net/v3/{MAILGUN_DOMAIN}/messages", | |
auth=("api", MAILGUN_API_KEY), | |
data={ | |
"from": "Other User <user@email.com>", | |
"to": to, | |
"subject": subject, | |
"text": text | |
} | |
) | |
''' | |
Parse CSV file | |
param {string} file_name | |
''' | |
def parse_csv(file_name): | |
pass | |
''' | |
Creates a message about a row | |
''' | |
def create_message(row): | |
pass | |
"""Executor""" | |
if __name__ == '__main__': | |
sys.exit(main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment