# https://github.com/sanuptpm/imap import imaplib import re import email import time import email.message from imap_conf import open_connection list_response_pattern = re.compile(r'\((?P<flags>.*?)\) "(?P<delimiter>.*)" (?P<name>.*)') # print "list_response_pattern :", list_response_pattern def parse_list_response(line): flags, delimiter, mailbox_name = list_response_pattern.match(line).groups() mailbox_name = mailbox_name.strip('"') return (flags, delimiter, mailbox_name) # Listing mailboxes def listing_mailboxes(): resp, data = c.list() # IMAP instance print "\nIMAP4_SSL instance :", c # First parameter of the c.list() print '\nResponse code:', resp # Second parameter of the c.list() print "\nmailboxes available for an account :", data # Get the status for line in data: print '\nServer response:', line # call for flags, d