Apple Mail keeps throwing "connection to the server failed" for my work account. Same account works on my phone and in the browser. Rebuilt the mailbox already.
Open Window > Connection Doctor in Mail first. It lists every incoming and outgoing server and shows which one is failing, which saves a lot of guessing.
If it's a Gmail or Outlook account, the usual cause is that the stored sign in expired or the password changed. Those use a browser style login now, so the cleanest fix is System Settings > Internet Accounts, remove the account, and add it back. For a work or ISP mailbox, go to Mail > Settings > Accounts > Server Settings and check the server names and password are still right, and that automatically manage connection settings is ticked unless your provider told you otherwise.