Guest User

Untitled

a guest
Nov 29th, 2018
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import smtplib
  2.  
  3. gmail_user = 'dummy@gmail.com'
  4. gmail_password = 'password'
  5.  
  6.  
  7.  
  8. sent_from = 'dummy@gmail.com'
  9. to = ['receiver@gmail.com']
  10. subject = 'OMG Super Important Message'
  11. body = "Hey, what's up?nn- You"
  12.  
  13. email_text = """
  14. From: %s
  15. To: %s
  16. Subject: %s
  17.  
  18. %s
  19. """ % (sent_from, ", ".join(to), subject, body)
  20.  
  21. try:
  22. server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
  23. print("establish connection successful")
  24. server.ehlo()
  25. print("identification successful")
  26. server.login(gmail_user, gmail_password)
  27. print("login successful")
  28. server.sendmail(sent_from, to, email_text)
  29. print("send mail successful")
  30. server.close()
  31. print('Email sent!')
  32. except:
  33. print('Something went wrong...')
Add Comment
Please, Sign In to add comment