mailboxes = None
# logged in status
logged_in = None
+ # skip shared folders
+ skip_shared_folders = None
- def __init__(self, server, username, password):
+ def __init__(self, server, username, password, skip_shared_folders = False):
"""Creates a connection and a user session."""
+ self.skip_shared_folders = skip_shared_folders
+
# connect to server
try:
self.mail_con = imaplib.IMAP4_SSL(server)
for mailbox in self.mailboxes:
logging.debug("Checking mailbox %s", mailbox[2])
+ # detect if mailbox is shared and if skip flag is set iterate further
+ if(self.skip_shared_folders and mailbox[2].split(mailbox[1])[0] == '"user'):
+ logging.info("Mailbox %s is shared and therefore skipped.", mailbox[2])
+ continue
# select mailbox if writable
try:
self.mail_con.select(mailbox[2])
# Work around unsolicited server responses in imaplib by clearing them
self.mail_con.response('STORE')
_result, data = self.mail_con.uid('STORE', mid_range, '+FLAGS', "(\Seen)")
- logging.info("New flags for messages %s are %s", mid_range, data)
+ logging.debug("New flags for messages %s are %s", mid_range, data)
except (self.mail_con.error) as ex:
raise UserWarning("Could not set the flags for some messages: %s", ex)
self.mail_con.expunge()