How it works...

This recipe downloads a user's first Google message via POP3. The download_email() method creates a mailbox object with Python, the POP3_SSL() class of poplib. We passed the Google POP3 server and port address to the class constructor. The mailbox object then sets up a user account with the user() method call. The password is collected from the user securely using the getpass module's getpass() method and then passed to the mailbox object. The mailbox's list() method gives us the email messages as a Python list.

This script first displays the number of email messages stored in the mailbox and retrieves the first message with the retr() method call. Finally, it's safe to call the quit() method on the mailbox to clean up the connection.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.218.221