subject line of the email the '\nnewline character separates the subject line from the main body of the email the return value from sendmail(is dictionary there will be one keyvalue pair in the dictionary for each recipient for whom email delivery failed an empty dictionary means all recipients were successfully sent the email disconnecting from the smtp server be sure to call the quit(method when you are done sending emails this will disconnect your program from the smtp server smtpobj quit(( bclosing connection ko sm pbd gsmtp'the in the return value means the session is ending to review all the steps for connecting and logging in to the serversending emailand disconnectingsee "sending emailon page imap just as smtp is the protocol for sending emailthe internet message access protocol (imapspecifies how to communicate with an email provider' server to retrieve emails sent to your email address python comes with an imaplib modulebut in fact the third-party imapclient module is easier to use this provides an introduction to using imapclientthe full documentation is at the imapclient module downloads emails from an imap server in rather complicated format most likelyyou'll want to convert them from this format into simple string values the pyzmail module does the hard job of parsing these email messages for you you can find the complete documentation for pyzmail at install imapclient and pyzmail from terminal window with pip install --user - imapclient=and pip install --user - pyzmail =on windows (or using pip on macos and linuxappendix has steps on how to install third-party modules retrieving and deleting emails with imap finding and retrieving an email in python is multistep process that requires both the imapclient and pyzmail third-party modules just to give you an overviewhere' full example of logging in to an imap serversearching for emailsfetching themand then extracting the text of the email messages from them import imapclient imapobj imapclient imapclient('imap example com'ssl=trueimapobj login('my_email_address@example com''my_secret_password'