Not an IMAP4 server
Sometimes Thunderbird will suddenly display a Mail server xyz is not an IMAP4 Server error message, despite the fact the IMAP server supports IMAP v4.1, and had been working okay. It appears to be a generic error message for IMAP accounts, thats sometimes displayed when Thunderbird can't map the error to another error message. While you may see it when it tries to connect to the mail server, its usually a transient error when you do something in quick succession like deleting multiple messages  .
There appear to be three common causes:
- Some sort of latency issue - if you repeat whatever you did slower the problem doesn't occur again. .
- Due to a connection timing out, or some sort of timing/load problem. In this case it might display the popup error message but still do what its supposed to. 
- Thunderbird asked the mail server what features it has (sent a IMAP Capability command) and got a answer that it didn't expect. This is most likely to occur with a email provider using a IMAP server that is not very compatible, such as Gmail. 
If none of this helps, you need to enable IMAP logging and look at the log files to understand whats going on. However, normally its just a transient error that you can ignore.
Wrong port or protocol
If you created a new account and always get this error message, that's a different problem. You may have specified a port normally used for POP or SMTP, for IMAP; or, you may have selected TLS or no encryption for a port that requires SSL.
|Protocol||Default port||SSL / TLS|
|SMTP||25||465 / 587|
Note: The default ports may also be used for TLS with some providers. Your email provider might support port 23, 2525 or 26 as a workaround for ISP's blocking SMTP port 25. Port 465 is the original port for SMTP over SSL/TLS, most SMTP servers now use 587 though some may support both.
Anti-virus or firewall blocking connections to the IMAP server
If your IMAP account used to work okay and you suddenly got this error message it might be due to an automated upgrade of your anti-virus or firewall program blocking connections to the IMAP server due to problems in its heuristics. For example, the real time shield in Avast 5 may block secure connections (use SSL/TLS or STARTTLS) to a mail server unless you reconfigure the account in Thunderbird not to use a secure connection and then reconfigure Avast to specify the name of the mail server (host), protocol, port and encryption type instead per this article.