The server returned the error: The server “imap.gmail.com” cannot be contacted on port 993
The canonical fix for troubleshooting Mail on OS X is to run the Connection Doctor (it's slightly buried in the Window menu without a keyboard shortcut to summon it) to isolate whether you have a general network error condition or a specific error on one or more of the accounts.

Each mail account will typically have two servers - different internet ports and potentially different username / password / authentication details.

Once you can isolate a specific error message on a specific port to a specific IP address, you can begin to troubleshoot whether you have a configuration issue, a network reachability issue or a server issue.

The show detail button is helpful to log the exact transactions and communications between Mail and the server.

If you have a vexing problem, I have found that disconnecting the network connection and quitting Mail (or forcing a reboot while the network is off) will let you start Mail and disable all Mail accounts except for one and also check for a stuck message or two in the Outbox. File those away as drafts so that you can then run connection doctor, re-enable the network and systematically work on the communication needed between the Mail program and your mail server.