secured smtp sample (secured_smtp_servers.diff)

sample patch - incomplete

download
# HG changeset patch
# Parent b5a9706f839e793f09e8cd46aa96359ecd887fa0
allow to use secured smtp servers like gmail server

diff --git a/cwconfig.py b/cwconfig.py
--- a/cwconfig.py
+++ b/cwconfig.py
@@ -1195,10 +1195,20 @@
         if connection to the smtp server failed, else True.
         """
         server, port = self['smtp-host'], self['smtp-port']
+        try:
+            smtp_user, smtp_password = self['sender-addr'].split(',')
+        except ValueError:
+            smtp_user = None
         SMTP_LOCK.acquire()
         try:
             try:
                 smtp = SMTP(server, port)
+                if smtp_user:
+                    # Log in on an SMTP server that requires authentication
+                    smtp.ehlo()
+                    smtp.starttls()
+                    smtp.ehlo()
+                    smtp.login(smtp_user, smtp_password)
             except Exception, ex:
                 self.exception("can't connect to smtp server %s:%s (%s)",
                                server, port, ex)