My journey started out reading the Python imaplib documentation for Python 2.7 and tinkering with the example near the end of the documentation. Unfortunately the example does not detail UID commands.
This project provides tools to clone email from one IMAP server to another using Python. It includes a command-line script (imapclone.py) and an optional graphical user interface (imapclone-gui.py).
betterimap is a wrapper library for Python's standard imaplib, that improves the experience. If refresh_token_callback is provided, it will be called with a dictionary in format {'access_token': '...' ...