Advertisement
xxmbabanexx

Send Email V2

Apr 13th, 2013
156
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.97 KB | None
  1.  
  2.  
  3.  
  4. #This is the email send v2 program. It can send messages from the terminal
  5.  
  6.  
  7. def how_many(username):
  8.     toaddrs = []
  9.     toaddrs.append(username)
  10.     while True:
  11.         print "Would you like to continue to add people to send messages to [Y/N]?"
  12.         YN = raw_input(">>>")
  13.         if YN.lower() == "y":
  14.             print "Please enter the name of another person to send this email to."
  15.             new_addr = raw_input(">>> ")
  16.             toaddrs.append(new_addr)
  17.         elif YN.lower() == "n":
  18.             print "Ok, thanks!"
  19.             break
  20.     return toaddrs
  21.  
  22.    
  23. username = raw_input("What is the account name of your gmail?")
  24. password = raw_input("What is your password?")
  25.  
  26.  
  27. import smtplib
  28. fromaddr = username
  29. toaddrs  = how_many(username)
  30.  
  31. msg = raw_input("What is your message?")
  32.  
  33. server = smtplib.SMTP('smtp.gmail.com:587')
  34. server.ehlo()
  35. server.starttls()
  36. server.login(username,password)
  37. server.sendmail(fromaddr, toaddrs, msg)
  38. server.quit()
Advertisement
RAW Paste Data Copied
Advertisement