Maildir 2 Gmail
The maildir2gmail.py script allows uploading a maildir directory into a Google Gmail account, using IMAP.
Scott Yang provides the original maildir2gmail.py script on his website. There is no license included, but according to a Tweet (copy) the license is "provided as is" (public domain).
The script in this repository contains a few additional features which I found useful while migrating data, as well as additional documentation how to use it.
./maildir2gmail.py [-f] [-n] [--ignore-missing-date] [--max-size=MAX_SIZE] -u <username> -p <app-password> <maildirs>
By default, all mails are uploaded to All Mail in Gmail, following the Google concept of "never delete mails, just archive everything". A folder can be specified using the -f option. Non-existent folders will be created automatically.
Mails can be marked as Unseen (new) using the -n option.
Use option --ignore-missing-date to ignore all messages with missing date. In this case, messages are imported to gmail with the last modification time of the file.
You can set the maximum size for messages with the option _--max-size=MAXSIZE (in bytes). Messages that are larger than the defined size are skipped. Default is 25 MB (Gmail limitation for IMAP).
Username and Password are required, IMAP for your mailbox must be turned on (do this in the Settings for your mailbox). In addition you have to create an app password.