Advertisement
Guest User

Untitled

a guest
Oct 30th, 2018
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import smtplib
  2.  
  3. try:
  4. server = smtplib.SMTP_SSL('smtp.gmail.com', 465)
  5. server.ehlo() # optional
  6. # ...send emails
  7. sent_from = "mikelovesoreos@gmail.com"
  8. to = ["ca.stevenlam@gmail.com"]
  9. subject = "Test email from python"
  10. body = "This is a successful email!"
  11.  
  12. email_text = """\
  13. From: %s
  14. To: %s
  15. Subject: %s
  16. %s
  17. """ % (sent_from, ", ".join(to), subject, body)
  18.  
  19. gmail_user = "mikelovesoreos@gmail.com"
  20. gmail_pass = "Sheridan1"
  21. server.login(gmail_user, gmail_pass)
  22. server.sendmail(sent_from, to, email_text)
  23. server.close()
  24.  
  25. except Exception as E:
  26. print("Something went wrong - ", E)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement