close imap session after each transaction

workspace
Brendan Howell 5 years ago
parent 133353232a
commit 1f645d0ab5

@ -190,6 +190,7 @@ class MailRoom(Bureau):
kode256.image("POr." + shortcode).save(msg.r_bc) kode256.image("POr." + shortcode).save(msg.r_bc)
self.print_full("email.html", msg=msg, shortcode=shortcode) self.print_full("email.html", msg=msg, shortcode=shortcode)
self.imapserv.logout()
@add_command("d", "Delete email") @add_command("d", "Delete email")
def delete(self, data): def delete(self, data):
@ -203,6 +204,7 @@ class MailRoom(Bureau):
self.imapserv.copy((imap_id), self.trashfolder) self.imapserv.copy((imap_id), self.trashfolder)
self.imapserv.delete_messages((imap_id)) self.imapserv.delete_messages((imap_id))
self.imapserv.expunge() self.imapserv.expunge()
self.imapserv.logout()
@add_command("sp", "Mark as spam") @add_command("sp", "Mark as spam")
def mark_spam(self, data): def mark_spam(self, data):
@ -217,6 +219,7 @@ class MailRoom(Bureau):
self.imapserv.copy((imap_id), self.spamfolder) self.imapserv.copy((imap_id), self.spamfolder)
self.imapserv.delete_messages((imap_id)) self.imapserv.delete_messages((imap_id))
self.imapserv.expunge() self.imapserv.expunge()
self.imapserv.logout()
@add_command("un", "Mark as unread") @add_command("un", "Mark as unread")
def mark_unread(self, data): def mark_unread(self, data):
@ -227,6 +230,7 @@ class MailRoom(Bureau):
imap_id = self.get_imap_id(shortcode) imap_id = self.get_imap_id(shortcode)
self._connect_imap() self._connect_imap()
self.imapserv.remove_flags(imap_id, [imapclient.SEEN]) self.imapserv.remove_flags(imap_id, [imapclient.SEEN])
self.imapserv.logout()
@add_command("re", "Reply with scan") @add_command("re", "Reply with scan")
def reply_scan(self, data): def reply_scan(self, data):
@ -280,6 +284,7 @@ class MailRoom(Bureau):
# flag as replied # flag as replied
self.imapserv.add_flags(imap_id, [imapclient.ANSWERED]) self.imapserv.add_flags(imap_id, [imapclient.ANSWERED])
self.imapserv.logout()
@add_api("unread", "Get unread mails") @add_api("unread", "Get unread mails")
def unread(self): def unread(self):
@ -320,6 +325,8 @@ class MailRoom(Bureau):
msgs.append(msg.__dict__) msgs.append(msg.__dict__)
self.imapserv.logout()
return msgs return msgs

Loading…
Cancel
Save