Manage mail account using python, forget about imap and just code what you supposed to do.
See documentation for more details.
Install using pip install ggmail
.
from ggmail import Account, Google
from ggmail.policy import from_contains, flagged
authentication = Google(username="[email protected]", password="secret")
with Account(authentication=authentication) as account:
inbox = account.inbox()
mailbox = account.create_mailbox("Favorite")
policy = from_contains("[email protected]") + flagged
messages = inbox.search(policy)
for message in messages:
message.copy(mailbox)
https://github.com/martinrusev/imbox is less high level than ggmail. I wanted something even more human than imbox.
https://github.com/charlierguo/gmail seems to be dead.
You can raise an issue and I will add it.