IMAP get sender name and body text?

前端 未结 2 1099
遇见更好的自我
遇见更好的自我 2021-01-12 01:30

I am using this code:

import imaplib
mail = imaplib.IMAP4_SSL(\'imap.gmail.com\')
mail.login(myusername, mypassword)
mail.list()
# Out: list of \"folders\" a         


        
2条回答
  •  醉梦人生
    2021-01-12 02:08

    from imap_tools import MailBox, A
    with MailBox('imap.mail.com').login('test@mail.com', 'password', 'INBOX') as mailbox:
        for msg in mailbox.fetch(A(all=True)):
            sender = msg.from_
            body = msg.text or msg.html
    

    IMAP high level lib: https://github.com/ikvk/imap_tools (I am author)

提交回复
热议问题