pykolab/imap
Jeroen van Meeuwen
vanmeeuwen at kolabsys.com
Tue Dec 9 19:18:12 CET 2014
pykolab/imap/__init__.py | 21 +++++++++++++++++----
1 file changed, 17 insertions(+), 4 deletions(-)
New commits:
commit 5db950d92bebf130d09fc7aeb53e3d0241aa84af
Author: Jeroen van Meeuwen (Kolab Systems) <vanmeeuwen at kolabsys.com>
Date: Tue Dec 9 19:18:08 2014 +0100
Use the correct scheme, hostname and port if so configured
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 23bf4a9..cf6ff07 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -122,7 +122,15 @@ class IMAP(object):
result = urlparse(uri)
- if hasattr(result, 'hostname'):
+ if hasattr(result, 'netloc'):
+ scheme = result.scheme
+ if len(result.netloc.split(':')) > 1:
+ hostname = result.netloc.split(':')[0]
+ port = result.netloc.split(':')[1]
+ else:
+ hostname = result.netloc
+
+ elif hasattr(result, 'hostname'):
hostname = result.hostname
else:
scheme = uri.split(':')[0]
@@ -131,12 +139,17 @@ class IMAP(object):
if not server == None:
hostname = server
- if port == None:
- port = 993
-
if scheme == None or scheme == "":
scheme = 'imaps'
+ if port == None:
+ if scheme == "imaps":
+ port = 993
+ elif scheme == "imap":
+ port = 143
+ else:
+ port = 993
+
uri = '%s://%s:%s' % (scheme, hostname, port)
# Get the credentials
More information about the commits
mailing list