How to configure IMAP in python

import imaplib
def open_connection(verbose=False):
# Connect to the server
connection = imaplib.IMAP4_SSL('servername')
# Login to our account
connection.login('username', 'password')
return connection
# if __name__ == '__main__':
# c = open_connection(verbose=True)
# try:
# resp, data = c.list()
# print "\nIMAP4_SSL instance :", c
# print '\nResponse code:', resp
# print "\nmailboxes available for an account :", data
# finally:
# c.logout()

Comments

Popular posts from this blog

AttributeError: Got AttributeError when attempting to get a value for field `abc` on serializer `PfleSerializer`. The serializer field might be named incorrectly and not match any attribute or key on the `QuerySet` instance. Original exception text was: 'QuerySet' object has no attribute 'abc'.

ImportError: No module named regex