summaryrefslogtreecommitdiffstats
path: root/pykolab/imap
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-12-09 19:18:08 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2014-12-09 19:18:08 +0100
commit5db950d92bebf130d09fc7aeb53e3d0241aa84af (patch)
tree5598b79b8fab32aafcb534eead3062376d0d2ca1 /pykolab/imap
parent5f711b830a66fd1795953193b8bfb82986568193 (diff)
downloadpykolab-5db950d92bebf130d09fc7aeb53e3d0241aa84af.tar.gz
Use the correct scheme, hostname and port if so configured
Diffstat (limited to 'pykolab/imap')
-rw-r--r--pykolab/imap/__init__.py21
1 files changed, 17 insertions, 4 deletions
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