Created
November 8, 2018 20:42
-
-
Save freddyheppell/a25b2d627393321865256613ced45500 to your computer and use it in GitHub Desktop.
Secret santa script with mailgun
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 random | |
import requests | |
def message(recipient): | |
message = "Hello,\n You have been assigned:\n\n"+ recipient[0] + "\n\n" + "REMEMBER: Spending limit is £5!\n\n Thank you,\n Santa" | |
return message | |
people = [ | |
("Name", "email") | |
] | |
random.shuffle(people) | |
for i in range(len(people)-1, -1, -1): | |
requests.post( | |
"https://api.mailgun.net/v3/MAILGUN_DOMAIN/messages", | |
auth=("api", "API_KEY_HERE"), | |
data={"from": "RoboSanta <FROM_EMAIL>", | |
"to": [people[i][1]], | |
"subject": "Your Secret Santa Has Been Assigned", | |
"text": message(people[i-1])}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment