Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. import smtplib
  2.  
  3. gmail_user = 'YOUR GOOGLE EMAIL'
  4. gmail_password = 'YOUR PASSWORD'
  5.  
  6. sent_from = gmail_user
  7. to = ['recipient1@gmail.com', 'recipient1@gmail.com']
  8. subject = 'This is very important email!'
  9. body = "Hey, what's up?\n\n- You"
  10.  
  11. email_text = """
  12. From: %s
  13. To: %s
  14. Subject: %s
  15.  
  16. %s
  17. """ % (sent_from, ", ".join(to), subject, body)
  18.  
  19. try:
  20. server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
  21. server.ehlo()
  22. server.login(gmail_user, gmail_password)
  23. server.sendmail(sent_from, to, email_text)
  24. server.close()
  25.  
  26. print("Email sent!")
  27. except:
  28. print("Something went wrong...")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement