From f5566c13254bb22c981a3945fb52a5b5aa606a81 Mon Sep 17 00:00:00 2001 From: Martin Zimmermann Date: Wed, 4 Mar 2015 21:44:39 +0100 Subject: [PATCH] encode username/password in SMTP auth only for Python 2, fix #146 --- isso/ext/notifications.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/isso/ext/notifications.py b/isso/ext/notifications.py index 46663bc..f027c20 100644 --- a/isso/ext/notifications.py +++ b/isso/ext/notifications.py @@ -63,11 +63,16 @@ class SMTP(object): timeout=self.conf.getint('timeout')) if self.conf.get('security') == 'starttls': - self.client.starttls(); + self.client.starttls() - if self.conf.get('username') and self.conf.get('password'): - self.client.login(self.conf.get('username').encode('ascii', errors='ignore'), - self.conf.get('password').encode('ascii', errors='ignore')) + username = self.conf.get('username') + password = self.conf.get('password') + if username is not None and password is not None: + if PY2K: + username = username.encode('ascii') + password = password.encode('ascii') + + self.client.login(username, password) return self.client