Browse Source

Separate if statements for starttls() and login() calls

guillaume chanaud 7 years ago
parent
commit
4651cacc46
1 changed files with 7 additions and 1 deletions
  1. 7 1
      tracim/tracim/lib/email.py

+ 7 - 1
tracim/tracim/lib/email.py View File

73
                 try:
73
                 try:
74
                     starttls_result = self._smtp_connection.starttls()
74
                     starttls_result = self._smtp_connection.starttls()
75
                     logger.debug(self, 'SMTP start TLS result: {}'.format(starttls_result))
75
                     logger.debug(self, 'SMTP start TLS result: {}'.format(starttls_result))
76
+                except Exception as e:
77
+                    logger.debug(self, 'SMTP start TLS error: {}'.format(e.__str__()))
78
+                    
79
+            if self._smtp_config.login:
80
+                try:
76
                     login_res = self._smtp_connection.login(self._smtp_config.login, self._smtp_config.password)
81
                     login_res = self._smtp_connection.login(self._smtp_config.login, self._smtp_config.password)
77
                     logger.debug(self, 'SMTP login result: {}'.format(login_res))
82
                     logger.debug(self, 'SMTP login result: {}'.format(login_res))
78
                 except Exception as e:
83
                 except Exception as e:
79
-                    logger.debug(self, 'SMTP start TLS error: {}'.format(e.__str__()))
84
+                    logger.debug(self, 'SMTP login error: {}'.format(e.__str__()))
85
+                
80
             logger.info(self, 'Connection OK')
86
             logger.info(self, 'Connection OK')
81
 
87
 
82
     def disconnect(self):
88
     def disconnect(self):