'Mail can't connect to the account' keeps appearing
The quickest way to run through the potential problems is to follow these steps:


Check the keychain to find any entries that match your email accounts, then delete all of them. Reboot.
Try to connect again, entering your passwords again.  Check email again and see if the error reoccurs.
If the error happens again, delete your email accounts using the system preferences, reboot, and then add them back. Check email again. 


If the error continues to occur after doing all that, you might think about taking your Mac into the Apple genius bar.