imapclient(function to create an imapclient object most email providers require ssl encryptionso pass the ssl=true keyword argument enter the following into the interactive shell (using your provider' domain name)import imapclient imapobj imapclient imapclient('imap example com'ssl=truein all of the interactive shell examples in the following sectionsthe imapobj variable contains an imapclient object returned from the imapclient imapclient(function in this contexta client is the object that connects to the server logging in to the imap server once you have an imapclient objectcall its login(methodpassing in the username (this is usually your email addressand password as strings imapobj login('my_email_address@example com''my_secret_password''my_email_address@example com jane doe authenticated (success)warning remember to never write password directly into your codeinsteaddesign your program to accept the password returned from input(if the imap server rejects this username/password combinationpython raises an imaplib error exception searching for email once you're logged onactually retrieving an email that you're interested in is two-step process firstyou must select folder you want to search through thenyou must call the imapclient object' search(methodpassing in string of imap search keywords selecting folder almost every account has an inbox folder by defaultbut you can also get list of folders by calling the imapclient object' list_folders(method this returns list of tuples each tuple contains information about single folder continue the interactive shell example by entering the followingimport pprint pprint pprint(imapobj list_folders()[(('\\hasnochildren',)'/''drafts')