Please examine the exception's message, as server is likely to inform you, why the connection was disconnected.
There are several situations when server may lock your account:
- you tried to login with incorrect credentials to many times,
- you are logging-in from a different location that you used to,
- your account doesn't have IMAP/POP3 protocol enabled
Usually logging-in through web interface is enough; sometimes a captcha must be filled (e.g. Google's unlock CAPTCHA)
However those situations/restrictions are server/email provider dependent and you'll need to contact your server administrator/email provider help page, to get information on how to proceed.
Here you can get more details on a connection attempt failed error, it also provides link to articles on enabling IMAP/POP3 protocols in Gmail and Exchange.