Mail is flaky with Network Solutions IMAP account
Recently (several months now) Mail is flaky in accessing the IMAP mail accounts I have with Network Solutions. Sometimes it works fine, and sending mail (SMTP) always has worked well. Sometimes, Mail will start refusing to access my email accounts (and always just on one domain name). Once it decides not to work with these accounts, when I try to access them it pops up a window asking for the password on the IMAP account. I put it in, and eventually get a message telling me that the username or password is unknown. If I then go to Preferences -> Accounts, go to the offending account, select the password, delete it, and put it in again (all steps are required), then click on save, there are no errors. Mail then download the outstanding emails on that account, but usually starts asking for the password again within a few minutes. I never have this problem using webmail or when I use Thunderbird. What setting do I have wrong? I have even deleted the account from Internet Accounts, then reloaded it and let the Mac set it up automatically. I have the box checked to tell Mail to automatically manage my account settings.
I have this problem on Mail for both Macs and on Mail for iPhone. It's always the same accounts, but Network Solutions can't find any problems.
MacBook (Retina, 12-inch, Early 2015), macOS Sierra (10.12.4), 8 G RAM, 512 G SSD