SHARE
TWEET

Untitled

a guest Dec 13th, 2016 140 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import smtplib
  2. import random
  3.  
  4. fromaddr    = 'your gmail email address'
  5. recieversList = ['Nick', 'Ricky', 'Alice', 'Collin', 'Vicky', 'Timothy', 'Wallace', 'Lauren']
  6. namesDictionary = {'nick@gmail.com': 'Nick', 'ricky@gmail.com': 'Ricky', 'alice@gyahoo.com': 'Alice', 'collin@hotmail.com': 'Collin', 'vicky@gmail.com': 'Vicky', 'timothy@aol.com': 'Timothy', 'wallace@someemial.com': 'Wallace', 'lauren@email.com': 'Lauren'}
  7.  
  8. username = 'your gmail username'
  9. password = 'your gmail password'
  10. server = smtplib.SMTP_SSL('smtp.gmail.com:465')
  11. server.login(username, password)
  12.  
  13. for email, name in namesDictionary.iteritems():
  14.     while True:
  15.         receiver = recieversList[random.randrange(len(recieversList))]
  16.         if not receiver == name:
  17.             break
  18.     recieversList.remove(receiver)
  19.  
  20.     subject = 'Secret Santa Recipient Assignment'
  21.     text = 'Hi %s, \n\nYour Secret Santa recipient is %s.\n Please remember, don\'t tell anyone your assignment.' % (name, receiver)
  22.     msg = 'Subject: %s\n\n%s' % (subject, text)
  23.     server.sendmail(fromaddr, email, msg)
  24.  
  25. server.quit()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top