This is a really annoying bug that seems to happen very regular on some systems. It looks like this has something to do with mail transport bugs and the wrong error being reported according to Stackexchange
I’m running Mac OS 10.8.1 and have a (personal) Gmail and a (work) Google mail account setup inside Mail client. Every few days (weekly?) Mail seems to forget my personal gmail password and I have to re-enter it again. The answer seems to be that network problems cause this and you can check by looking at the console for errors.
This seems likely as we are using a hoster based outside of the US for things and it does seem to happen to shared hosters as well.
At Apple Helpwriter, then have an old post on this topic where you see the password is suddenly blank:
If you look in Mail > Preferences… > Account Information, you may be surprised to find the password field blank. You may be even more surprised that when you enter it, click out of the tab and hit ‘Save’, the field is blank again the next time you look!
There are a couple of different solutions to this problem, and both revolve around the keychain. One solution is to try a keychain repair. If the repair indicates nothing is wrong, then you have a problem with the access controls. Let’s deal with each in the order you should do them.
Verify and Repair Keychain
1. Go to Applications > Utilities > Keychain.app and double-click to open it.
2. From the menubar, choose Keychain Access > Keychain First Aid
3. Type in your admin password in the field, and click Start to verify the keychain. If the keychain needs repairing, click the radio button for repair and click Start again. Run the ‘Verify’ task one more time.
Repair Access controls
If the above didn’t solve your problem, or the keychain verify/repair task indicated no problems, then you’re going to need to look at the access controls on each Mail keychain.
4. In the left-hand pane, click login in the top panel, and Passwords in the bottom panel.
5. Look for your Mail/imap keychains. Click on one of them, and then press command-i on your keyboard, or click the little ‘i‘ at the bottom of the Keychain window.
6. Click the Access Control tab in the window that pops up. Click ‘Confirm before allowing access’, and make sure Mail is in the list of apps in the window underneath that is always allowed access. Go and do the same for any other Mail/imap keychains in the window, and your problem should be fixed.
7. If the settings above were already configured correctly or they do not resolve the problem, click on the Attributes tab (next to the Access Control tab).
8. Click on the ‘Show password’ box. If everything is OK, you should get a request to put in your admin password. Chances are, though, if you’ve got to this stage you will instead get a message saying ‘Access is restricted’ and no option to do anything about it.
9. If you don’t get asked for the password, close the information box (red radio button, top-left), and control-click on your mail/imap keychain in the Keychain window. Choose ‘Delete <name of keychain)'. Do the same for any other keychain's exhibiting the same problem.
10. You can now go back to Mail, and enter your password in the Account preferences box.
Other sites point to keychain access problems:
Most of the answers involving deleting the password from Keychain Access and trying again.
Another fellow noticed this problem with google two step verification where he lost IMAP but not SMTP access. http://activerain.trulia.com/blogsview/4497408/bug–apple-ios-mail-app-loses-gmail-password-
So the search goes on
I’ve noticed a potentially related problem in that with Yosemite, the iCloud keychain access seems to forget that it is enabled every few days on various machines. I wonder if that is one of the problems.