Mac Mail forgets my email password every few days. How to fix it?
For years, and it still is true, I've had the pattern that Mail claims to have forgot the password but it's actually reacting to some other problem. If you hit the (Cancel) button on the "enter new password" dialog, you should find that it continues to work just fine.

At one time, this syndrome was clearly associated with network problems talking to the mail server (Microsoft Exchange, as it happened); I could tell this by correlating messages in the Console log. More recently, I haven't always been able to identify the underlying problem, but the trick of canceling the password prompt still seems to work all the time, for me.