Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv, smtplib
- # Get the giver information
- santaG = []
- with open("secret_santa.csv", "rb") as csvfile:
- csvreader = csv.reader(csvfile, delimiter=",")
- for row in csvreader:
- santaG.append(row[0])
- # Get the receiver information
- santaR = []
- with open("RECEIVER_SECRET_SANTAS.csv", "rb") as csvfile:
- csvreader = csv.reader(csvfile, delimiter=",")
- for row in csvreader:
- santaR.append(row[0])
- # Find the recipient
- try:
- person = santaR[santaG.index(raw_input("Enter the name of the giver: "))]
- except ValueError:
- print "Name not found"
- # Set up the email server
- fromaddr = 'benjisthrowaway@gmail.com'
- username = 'benjisthrowaway@gmail.com'
- password = 'SECRETsantaFORlyfe'
- server = smtplib.SMTP('smtp.gmail.com:587')
- server.starttls()
- server.login(username,password)
- # Make the message with the recipient
- msg1 = "Hi,\n\nFor Secret Santa, you have been assigned "
- msg2 = " for your secret Santa.\n\nThe budget is \xA33 to \xA310, and the we are " + \
- "bringing the gifts in on Monday 14th ideally.\n\n" + "Any questions " + \
- "should be emailed to benji.john.marshall@gmail.com because I am not " + \
- "looking at this account to maintain secrecy.\n\nThanks, and have fun!" + \
- "\nBenji's Bot"
- msg = msg1 + person + msg2
- # Add the new address of the giver, and send them the info
- toaddrs = raw_input("Add a new email: ")
- server.sendmail(fromaddr, toaddrs, msg)
- print "Sent!"
- server.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement