aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVG <vg@devys.org>2015-12-15 00:02:14 +0100
committerVG <vg@devys.org>2015-12-15 00:02:14 +0100
commit7f679638c4ec54fe5bdf656b07018f4e753b9439 (patch)
treee96e793fdef309a62ece296b3a18c22c9ad61dbc
parentdea2a328ccd3e64d4942e930878d33ce30167f55 (diff)
downloadcliml-7f679638c4ec54fe5bdf656b07018f4e753b9439.tar.gz
climl-7f679638c4ec54fe5bdf656b07018f4e753b9439.tar.bz2
climl-7f679638c4ec54fe5bdf656b07018f4e753b9439.zip
try to do the first connection
-rw-r--r--climl_imap_bridge.py18
1 files changed, 11 insertions, 7 deletions
diff --git a/climl_imap_bridge.py b/climl_imap_bridge.py
index 8549a43..fc48e9a 100644
--- a/climl_imap_bridge.py
+++ b/climl_imap_bridge.py
@@ -5,13 +5,15 @@ import subprocess
import confparser
import imapclient
-def monitor_mailbox(server, port, user, password, conf):
- if conf.ssl:
- imapserv = imaplib.IMAP4_SSL(server, port)
- else:
- imapserv = imaplib.IMAP4(server, port)
- if conf.starttls:
- imapserv.starttls()
+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')
+ if conf.get('imap.start_tls', 'false').lower() == 'true':
+ connection.start_tls()
+ print('connection succeed')
+ return connection
def main():
confpath = os.path.expanduser('~') + '/temp/conf.cfg'
@@ -20,7 +22,9 @@ def main():
password_command = conf.get('imap.password_command', None)
if password_command:
password = subprocess.check_output(password_command, shell=True)
+ password = password.rstrip().decode('utf8')
print('got pasword:', password)
+ connection = connect_to_imap(conf, password)