If you are getting an error message that the connection to the IMAP server failed to your system, here is the simple and best example for the fix that issue on your server.
Source: https://mailsetuponline.org/em-client-imap-an-attempt-to-connect-failed