summaryrefslogtreecommitdiffstats
path: root/pykolab/imap
diff options
context:
space:
mode:
authorJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-10-19 13:19:18 +0100
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2011-10-19 13:19:18 +0100
commit11b08b988b983043f0c058014831228d4a4db985 (patch)
treee3f9e96b09eea0fce54c6388c2b96d03f0beaa9a /pykolab/imap
parent46884732b48f8ffb8d3c9b17c2e163f31a6eb4db (diff)
downloadpykolab-11b08b988b983043f0c058014831228d4a4db985.tar.gz
Correct attempting to load the wrong library (imap -> imaplib)
Circumvent cases where the port is not set
Diffstat (limited to 'pykolab/imap')
-rw-r--r--pykolab/imap/__init__.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/pykolab/imap/__init__.py b/pykolab/imap/__init__.py
index 003db79..55bfa02 100644
--- a/pykolab/imap/__init__.py
+++ b/pykolab/imap/__init__.py
@@ -47,6 +47,9 @@ class IMAP(object):
def connect(self, uri=None, login=True):
backend = conf.get('kolab', 'imap_backend')
+ hostname = None
+ port = None
+
if uri == None:
uri = conf.get(backend, 'uri')
@@ -58,6 +61,9 @@ class IMAP(object):
scheme = uri.split(':')[0]
(hostname, port) = uri.split('/')[2].split(':')
+ if port == None:
+ port = 993
+
# Get the credentials
admin_login = conf.get(backend, 'admin_login')
admin_password = conf.get(backend, 'admin_password')
@@ -80,8 +86,8 @@ class IMAP(object):
self._imap[hostname].login(admin_login, admin_password)
else:
- import imap
- self._imap[hostname] = imap.IMAP(uri)
+ import imaplib
+ self._imap[hostname] = imaplib.IMAP4(hostname, port)
# Actually connect
if login:
log.debug(_("Logging on to generic IMAP server %s") %(hostname), level=8)