encode username/password in SMTP auth only for Python 2, fix #146
This commit is contained in:
parent
596acb7f79
commit
f5566c1325
@ -63,11 +63,16 @@ class SMTP(object):
|
|||||||
timeout=self.conf.getint('timeout'))
|
timeout=self.conf.getint('timeout'))
|
||||||
|
|
||||||
if self.conf.get('security') == 'starttls':
|
if self.conf.get('security') == 'starttls':
|
||||||
self.client.starttls();
|
self.client.starttls()
|
||||||
|
|
||||||
if self.conf.get('username') and self.conf.get('password'):
|
username = self.conf.get('username')
|
||||||
self.client.login(self.conf.get('username').encode('ascii', errors='ignore'),
|
password = self.conf.get('password')
|
||||||
self.conf.get('password').encode('ascii', errors='ignore'))
|
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
|
return self.client
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user