This is the way projects used to be, and surprisingly excellent ones still are.
The amount of knowledge built into this is incredible:
https://imapsync.lamiral.info/S/news.shtml
// imapsync did 14M to 21M mailboxes transfers per month in 2024, or 0.22% of ALL email traffic
I see that there's a free (for up to 3GB, pay for more) migration service offered there now, too: https://imapsync.lamiral.info/X/
That's a pretty cool way to support the project.
[1] https://isync.sourceforge.net/
[2] https://imapsync.lamiral.info/FAQ.d/FAQ.Two_Ways_Sync.txt