I want to download my emails via IMAP from email account and upload them to another. I want to do that manually in Python. I know how to retrieve my emails via IMAP, but how can I actually "upload" them to my another email account? Is there a standard way or does that depend on my 2nd email server?
You can upload with python as well:
import imaplib # an alternative for IMAP4_SSL is IMAP4 if you're doing this locally imap = imaplib.IMAP4_SSL(your_2nd_server, its_imap_portnumber) imap.login(user_name, password)
and then for each message you downloaded:
imap.append(mailbox, , delivery_time, message)
You have to get the delivery time out of the message header for this.