Properly formatted example for Python iMAP email access?

前端 未结 4 1944
故里飘歌
故里飘歌 2021-02-01 09:57

tldr: Can someone show me how to properly format this Python iMAP example so it works?

from https://docs.python.org/2.4/lib/imap4-example.html

<         


        
4条回答
  •  爱一瞬间的悲伤
    2021-02-01 10:34

    import imaplib
    
    # you want to connect to a server; specify which server
    server= imaplib.IMAP4_SSL('imap.googlemail.com')
    # after connecting, tell the server who you are
    server.login('email@gmail.com', 'password')
    # this will show you a list of available folders
    # possibly your Inbox is called INBOX, but check the list of mailboxes
    code, mailboxen= server.list()
    print mailboxen
    # if it's called INBOX, then…
    server.select("INBOX")
    

    The rest of your code seems correct.

提交回复
热议问题