Due to the nature of the work involved, this is not currently possible. However, there are third party tools developed, which can do it for you.
One of them is "imapsync". You can have a look at this guide on using it: https://www.howtoforge.com/how-to-migrate-mailboxes-between-imap-servers-with-imapsync. You will need SSH access to your old email server or any other server, as we do not provide SSH access to our mail servers.