Advertisement
Guest User

Untitled

a guest
Aug 10th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. def sendEmail(e):
  2. SMTPserver = 'outlook.office365.com'
  3. sender = 'x'
  4. destination = ['x']
  5.  
  6. USERNAME = "x"
  7. PASSWORD = "x"
  8.  
  9. text_subtype = 'plain'
  10.  
  11. content="""
  12. Test message
  13. """
  14.  
  15. subject = str(e)
  16.  
  17. try:
  18. msg = MIMEText(content, text_subtype)
  19. msg['Subject'] = subject
  20. msg['From'] = sender
  21.  
  22. conn = SMTP(SMTPserver) #THIS IS WHERE IT GETS STUCK
  23. conn.set_debuglevel(False)
  24. conn.login(USERNAME, PASSWORD)
  25. try:
  26. conn.sendmail(sender, destination, msg.as_string())
  27. finally:
  28. conn.quit()
  29.  
  30. except Exception:
  31. print( "mail failed" ) # give a error message
  32. print(traceback.format_exc())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement