Troubleshooting IMAP Connectivity: Unable to authenticate to IMAP server. IMAP command failed: Login failed.

The first step is to check if the Courier IMAP server is accepting connections. Open a terminal window and type:

telnet hostname 143

Replace hostname with the IMAP server's DNS name. This expected results would look like this:

$ telnet imap.example.com 143

If you get the error "no login failed" then you need to check the following:

1. Make sure IMAP Service is running.

2. You should make sure that you are using the correct password and that the mail username is in the format:

3. Make sure there is correct name in your exchange server certificate.

Please check your certificate settings:

Get-ExchangeCertificate | fl

I noticed that the InternalConnectionSettings is pointed to Test2.contoso.com but the X509CertificateName is using Remote.domain.com. If there is a certificate with Test2.contoso.com, please change the X509CertificateName to it to have a try:

Set-IMAPSettings -Identity Test2\1  -X509CertificateName Test2.contoso.com

Then restart Microsoft Exchange IMAP service in Exchange server.