Mac Mail opens a lot of IMAP connections per client. If you have a lot of Mac Mail clients open on a local network, it's possible that for your whole internal network, you are going over a server-defined limit for your IP.
As far as I know there is no way to configure how many IMAP connections Mac Mail creates. One thing you can do is to close (right-click, exit) other Mac Mail clients on the network and see if your client can then connect.
For smaller email providers you might ask them to raise the IMAP connection limit.