Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import smtplib
- import random
- import sys
- import os
- import smtplib
- from email.mime.text import MIMEText
- class person(object):
- def __init__(self, name, email):
- self.name = name
- self.email = email
- def __str__(self):
- return self.name
- def santa_mail(s, name, partner):
- msg = MIMEText("""
- Hello {name},
- You are receiving this message becasue you expressed interest in
- the Hillenbrand 4E Secret Santa 2014. Following
- is your assigned partner:
- {partner}
- You have until Saturday, December 6 to get them a gift,
- please do limit yourself to $15 as a curtesy to everyone,
- and try to make it something they'll enjoy!
- Don't forget - your Santa is a surprise, so don't tell them
- who you are ;D
- Thank you, and Merry Christmas,
- Your humble matchmaker,
- Tyler's Python Script.""".format(name=name, partner=partner)
- )
- msg["Subject"] = "Hilly4E Secret Santa"
- msg["From"] = "tphilbri@purdue.edu"
- msg["To"] = name.email
- #print(msg)
- #s.send_message(msg)
- def getnames():
- ret = []
- try:
- with open(sys.argv[1], "r") as f:
- for l in f:
- n, m = l.split("\t")
- ret.append(person(n, m))
- return ret
- except Exception:
- print("Error, file and stuff")
- exit(1)
- def oato(l):
- lenl = len(l)
- for i in range(lenl):
- yield (l[i], l[(i + 1) % lenl])
- def main():
- x = getnames()
- random.shuffle(x)
- s = 0
- #s = smtplib.SMTP_SSL("smtp.gmail.com", 465)
- #s.login("t5j6p9@gmail.com", "dpwzbydqcdqxhqfn")
- for i in oato(x):
- print(tuple(map(lambda x: x.name, i)))
- #santa_mail(s, *i)
- #s.quit()
- if __name__ == "__main__":
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement