Guest User

Untitled

a guest
Oct 8th, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. """
  2. Proxy smtp to a starttls server with authentication, from a local
  3. connection.
  4. """
  5. from inbox import Inbox
  6. from smtplib import SMTP
  7.  
  8. inbox = Inbox()
  9.  
  10. SMTP_HOST = 'mail.example.com'
  11. SMTP_USERNAME = 'username'
  12. SMTP_PASSWORD = 'password'
  13.  
  14. @inbox.collate
  15. def handle(to, sender, body):
  16. """
  17. Forward a message via an authenticated SMTP connection with
  18. starttls.
  19. """
  20. conn = SMTP(SMTP_HOST, 25, 'localhost')
  21.  
  22. conn.starttls()
  23. conn.ehlo_or_helo_if_needed()
  24. conn.login(SMTP_USERNAME, SMTP_PASSWORD)
  25. conn.sendmail(sender, to, body)
  26. conn.quit()
  27.  
  28. inbox.serve(address='0.0.0.0', port=4467)
Add Comment
Please, Sign In to add comment