Skip to content

Instantly share code, notes, and snippets.

@freddyheppell
Created November 8, 2018 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save freddyheppell/a25b2d627393321865256613ced45500 to your computer and use it in GitHub Desktop.
Save freddyheppell/a25b2d627393321865256613ced45500 to your computer and use it in GitHub Desktop.
Secret santa script with mailgun
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