aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--climl_imap_bridge.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/climl_imap_bridge.py b/climl_imap_bridge.py
index fc48e9a..f4d75e7 100644
--- a/climl_imap_bridge.py
+++ b/climl_imap_bridge.py
@@ -6,13 +6,21 @@ import confparser
import imapclient
def connect_to_imap(conf, password):
- connection = imapclient.IMAPClient(conf.get('imap.server'),
- conf.get('imap.username'),
- password,
- ssl=conf.get('imap.ssl', 'true').lower() == 'true')
+
+ ssl_context = None
+
+ if conf.get('imap.ssl_ca', None):
+ ssl_context = imapclient.create_default_context(
+ cafile=os.path.expanduser(conf.get('imap.ssl_ca')))
+
+ connection = imapclient.IMAPClient(host=conf.get('imap.server'),
+ ssl=conf.get('imap.ssl', 'true').lower() == 'true',
+ ssl_context=ssl_context)
if conf.get('imap.start_tls', 'false').lower() == 'true':
- connection.start_tls()
+ connection.start_tls(ssl_context=ssl_context)
print('connection succeed')
+ connection.login(username=conf.get('imap.username'), password=password)
+ print('successfuly logged')
return connection
def main():