Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. import csv, smtplib
  2.  
  3. # Get the giver information
  4. santaG = []
  5. with open("secret_santa.csv", "rb") as csvfile:
  6. csvreader = csv.reader(csvfile, delimiter=",")
  7. for row in csvreader:
  8. santaG.append(row[0])
  9.  
  10. # Get the receiver information
  11. santaR = []
  12. with open("RECEIVER_SECRET_SANTAS.csv", "rb") as csvfile:
  13. csvreader = csv.reader(csvfile, delimiter=",")
  14. for row in csvreader:
  15. santaR.append(row[0])
  16.  
  17. # Find the recipient
  18. try:
  19. person = santaR[santaG.index(raw_input("Enter the name of the giver: "))]
  20. except ValueError:
  21. print "Name not found"
  22.  
  23. # Set up the email server
  24. fromaddr = 'benjisthrowaway@gmail.com'
  25. username = 'benjisthrowaway@gmail.com'
  26. password = 'SECRETsantaFORlyfe'
  27. server = smtplib.SMTP('smtp.gmail.com:587')
  28. server.starttls()
  29. server.login(username,password)
  30.  
  31. # Make the message with the recipient
  32. msg1 = "Hi,\n\nFor Secret Santa, you have been assigned "
  33. msg2 = " for your secret Santa.\n\nThe budget is \xA33 to \xA310, and the we are " + \
  34. "bringing the gifts in on Monday 14th ideally.\n\n" + "Any questions " + \
  35. "should be emailed to benji.john.marshall@gmail.com because I am not " + \
  36. "looking at this account to maintain secrecy.\n\nThanks, and have fun!" + \
  37. "\nBenji's Bot"
  38. msg = msg1 + person + msg2
  39.  
  40. # Add the new address of the giver, and send them the info
  41. toaddrs = raw_input("Add a new email: ")
  42. server.sendmail(fromaddr, toaddrs, msg)
  43. print "Sent!"
  44.  
  45. server.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement