Read Gmail using Python

Read gmail with Python?

The poplib module can be used to download mails from an email server such as gmail.

The protocol used between your computer and the email server is called POP (Post Office Protocol). This protocol can not send mail.

First enable POP support in gmail. .

Related course:

Gmail with Python

We can conect with gmail using:

Read an email

Read gmail messages using this code:

We login with the first block. We get all items on the server using server.list(). We go on downloading the first message in the list and finally output it. If you want to output the message data simply uncomment the line message.fp.read()

Previous Post
Next Post

8 Comments

  • Is there a list of other commands like find number of unread emails or others?

  • arnav says:

  • BoB says:

    #POP enabled in gmail account…….
    #No known temporary system problem at gmail. All fine in chrome browser……….
    #Running ‘connect with gmail’ gives the following ……..
    #Login ID and pw are correct………
    #Any ideas would be appreciated. ……..

  • Boycha says:

    what is resp, items, octets

Leave a Reply