reorganize mail folders (not in V4 on Sierra) A while ago, after filling my MacBookPro disk, I (stupidly!) moved my Mail (all IMAP or Gmail) folders to an external disk (using Terminal). After cleaning up my disk, I did


  Mailbox > Rebuild


on each of my Mail folders, but on my work IMAP account my files has mostly disappeared, so I had to recover them from a backup performed by the IT dept. at work. However, several problems arose: 


the folders are no longer in ~/Library/Mail/V4 (Sierra)
the Message List is often incomplete (but using Spotlight helps locate the missing messages)
the Rules and Signatures have disappeared.


What should I do?


Copy the mailbox contents from another Mac (desktop, High Sierra)? What precise files (and Preference files) should I copy?
Upgrade my laptop MacOS to Mojave (hoping for the Mail folders to magically appear in ~/Library/Mail/V5)?
I just solved my problem by:


turning off all Internet accounts (keeping them on other iCloud machines)
updating to Mojave
following the steps in https://appletoolbox.com/mail-not-working-after-macos-mojave-upgrade-how-to-fix/, which basically deletes several Mail-related files in ~/Library/Containers and ~/Library/Mail.


This allowed me to recover my mailboxes and also recover a lost synchronization in Notes between my Mac and iPhone.