IT is a minefiled. The big vendors are not on our side. KISS is the golden IT rule.
troubleshooting
Apple Mail: Fixing Broken IMAP accounts after a server move
Trouble with your IMAP after a server move? Here are the setting you need to change in Apple Mail to save messages properly.