It is possible that the ports are blocked by your service provider.
In some cases, this can also be caused by ipv6 issues.
A similar problem was solved here - the service provider had blocked the port - maybe check that using
smtp check
nc -vv outgoing.server 465
IMAP test
nc -vv incoming.server 993