I'm using python imaplib to fetch email from server. All things goes well.
when I "fetch", the thread will be blocked and whole attachment will be fetched as base64 string in payload.
I wonder how or what to do if the attachment is large or big? And I also wonder is there a way to fecth or load the attachment like stream?
server = IMAP4(imapserver)
server.login(account, password)
print(server.select("INBOX", readonly=True))
unseen = server.search(None, "TEXT xxxx")
mailidx = unseen[1][0]
types, data = server.fetch(mailidx, "RFC822") # blocked and wait for load
msg_struct = BytesParser(policy=default).parsebytes(data[0][1])
for part in msg_struct.walk():
........
part.get_payload(decode=True) # return whole file in memory