It seems that port 993 was blocked. You can check it in the Windows Firewall(Advanced Security). Besides, make sure the Microsoft Exchange IMAP/IMAPBE services are running, and make sure your certificate is assigned the IMAP service(You could check that by running the command "Get-ExchangeCertificate | fl Subject, Services).
Testing Exchange 2019 / Imap connectivity
FDVA
1
Reputation point
We've enabled the IMAP4 services, and set the External Connection Settings
Confirmed the Exchange Certificate has IMAP enabled
I tried testing the connection from https://testconnectivity.microsoft.com/tests/Imap/input
it shows port 993 is opened, but fails on the certificate
error
The Microsoft Connectivity Analyzer is probing the TCP endpoint [X.X.X.X ] on port 993 to detect which SSL/TLS protocols and cipher suites are enabled.
We were unable to determine which SSL and TLS protocols are enabled. This is usually because we couldn't connect.