mailroom should fail gracefully on stale IMAP session.

workspace
Brendan Howell 4 years ago
parent 5859addc46
commit 52880fa58c

@ -54,11 +54,10 @@ class MailRoom(Bureau):
self.trashfolder = self.config["user"]["trashfolder"] self.trashfolder = self.config["user"]["trashfolder"]
self.imap_ssl = self.config["user"]["ssl"] self.imap_ssl = self.config["user"]["ssl"]
self.imapserv = imapclient.IMAPClient(self.host, use_uid=True, ssl=self.imap_ssl) self.last_login = 0
self.imapserv.login(self.login, self.password) self._connect_imap()
self.imapserv.select_folder("INBOX")
self.last_login = time.time()
else: else:
#TODO: do this with small print
print("you need to configure an IMAP account!") print("you need to configure an IMAP account!")
print("add a user: section to PO.yml with:") print("add a user: section to PO.yml with:")
print(" login: mylogin") print(" login: mylogin")
@ -77,7 +76,6 @@ class MailRoom(Bureau):
connect / reconnect to imap server connect / reconnect to imap server
""" """
def run_login(): def run_login():
self.imapserv.logout()
self.imapserv = imapclient.IMAPClient(self.host, use_uid=True, ssl=self.imap_ssl) self.imapserv = imapclient.IMAPClient(self.host, use_uid=True, ssl=self.imap_ssl)
self.imapserv.login(self.login, self.password) self.imapserv.login(self.login, self.password)
self.imapserv.select_folder("INBOX") self.imapserv.select_folder("INBOX")

Loading…
Cancel
Save