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)
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

Loading…
Cancel
Save