To provide further assistance, please follow @fabian adviced steps and check your logs.
If your logs do not provide any helpful hints, please share your mail configuration and which hoster you are trying to connect to.
I´ve connected to dozens of mail hosters, for myself and for corporate clients. When there were connections errors, there has always been a reason for it.