Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2016
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. import smtplib
  2.  
  3. gmail_user = 'XXXX@gmail.com'
  4. gmail_password = 'XXXXXXX'
  5.  
  6. from_add = gmail_user
  7. to = ["AAAAAAAA@gmail.com"]
  8. subject = 'testing'
  9. body = 'Hello World! \nThis is a test'
  10.  
  11. email_text = """\
  12. From: %s
  13. To: %s
  14. Subject: %s
  15. %s
  16. """%(from_add, ", ".join(to), subject, body)
  17.  
  18. try:
  19. smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
  20. smtpObj.ehlo()
  21. smtpObj.starttls()
  22. smtpObj.login(gmail_user, gmail_password)
  23. smtpObj.sendmail(from_add, to, email_text)
  24. smtpObj.close()
  25. print 'Email sent'
  26. except:
  27. print 'Something went wrong'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement