For troubleshooting connectivity issues with Apple Mail and an IMAP type account:
Ensure Mail is not running. This presumes your account (setup) is using SSL/TLS for security (thus port 993) as you should be.
While logged in as the user in question, use the Terminal to issue:
/Applications/Mail.app/Contents/MacOS/Mail -LogSocketErrors YES -LogActivityOnHost your.mailserver.com -LogIMAPErrors YES -LogActivityOnPort 993 &> ~/Desktop/ConnectionLog.txt
Quit Mail from within the app after a minute or less. You can watch for activity (eg: to complete) in the Activity window.
For an Exchange account (which requires and uses Microsoft’s EWS),
ensure Mail is not running, and while logged in as the user in question, use the Terminal to issue:
/Applications/Mail.app/Contents/MacOS/Mail -LogHTTPActivity YES -LogEWSAutodiscoveryActivity YES >& ~/Desktop/MailEWS.log
Use the Window menu in Mail to bring up the Activity window, and wait for connection(s) to complete. Or give it a minute.
Quit Mail from within the app, and check the log.