How to move a local copy of my mailbox to a new IMAP server?

The first idea I had:

Can you just forward the emails to the new account? But that means some data is not right like the sender and the recipient.

So my other attempt:

To repeat your situation I used a software which blocks the Internet connection. And I was able to create a .mbox file. (the screenshot was taken later so the iCloud account is online again)

export as .mbox

In mail app I imported the .mbox file as a local import. Then I selected the mail and clicked move to and moved it to my other mail account.

Import Mailboxes

I hope I could repeat your situation well, if not please tell me which steps not work for you. Maybe my answer is completely not working for you. I think there are much cleaner ways to do your task with python scripts (like this, or that), but I think this solution is the easiest.