summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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)