From 1f645d0ab5457fb81b7cd882283ce25c3fc08119 Mon Sep 17 00:00:00 2001 From: Brendan Howell Date: Thu, 11 Jun 2020 14:35:47 +0200 Subject: [PATCH] close imap session after each transaction --- screenless/bureau/mailroom/mailroom.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/screenless/bureau/mailroom/mailroom.py b/screenless/bureau/mailroom/mailroom.py index ce0101c..6345c8e 100644 --- a/screenless/bureau/mailroom/mailroom.py +++ b/screenless/bureau/mailroom/mailroom.py @@ -190,6 +190,7 @@ class MailRoom(Bureau): kode256.image("POr." + shortcode).save(msg.r_bc) self.print_full("email.html", msg=msg, shortcode=shortcode) + self.imapserv.logout() @add_command("d", "Delete email") def delete(self, data): @@ -203,6 +204,7 @@ class MailRoom(Bureau): self.imapserv.copy((imap_id), self.trashfolder) self.imapserv.delete_messages((imap_id)) self.imapserv.expunge() + self.imapserv.logout() @add_command("sp", "Mark as spam") def mark_spam(self, data): @@ -217,6 +219,7 @@ class MailRoom(Bureau): self.imapserv.copy((imap_id), self.spamfolder) self.imapserv.delete_messages((imap_id)) self.imapserv.expunge() + self.imapserv.logout() @add_command("un", "Mark as unread") def mark_unread(self, data): @@ -227,6 +230,7 @@ class MailRoom(Bureau): imap_id = self.get_imap_id(shortcode) self._connect_imap() self.imapserv.remove_flags(imap_id, [imapclient.SEEN]) + self.imapserv.logout() @add_command("re", "Reply with scan") def reply_scan(self, data): @@ -280,6 +284,7 @@ class MailRoom(Bureau): # flag as replied self.imapserv.add_flags(imap_id, [imapclient.ANSWERED]) + self.imapserv.logout() @add_api("unread", "Get unread mails") def unread(self): @@ -320,6 +325,8 @@ class MailRoom(Bureau): msgs.append(msg.__dict__) + self.imapserv.logout() + return msgs