How it works...

The preceding script takes a Google username from the command line and calls the check_email() function. This function creates an IMAP mailbox with the IMAP4_SSL() class of imaplib, which is initialized with Google's IMAP server and default port.

Then, this function logs in to the mailbox with a password, which is captured by the getpass() method of the getpass module. The inbox folder is selected by calling the select() method on the mailbox object.

The mailbox object has many useful methods. Two of them are search() and fetch() that are used to get the first email message. Finally, it's safer to call the close() and logout() method on the mailbox object to end the IMAP connection.

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

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