This worked for me once, for about 3 hours. Then the problem occured again. Each time I would then delete the approriate keychain, however it never fixed it after that first time, even for a while. Deleting preferences does not fixi it either. There is no discernable reason why it will not accept passwords and then suddleny it works for a while - then breaks for hours, then works. Usually just repeat clicking 'cancel' on the password dialog box that pops up - gets some mail coming through. My iPhone 5c iOS 7.0 to the same imap account works fine BTW - so this is Mac Mail specific.
My experience with this repeated password request using an imap account over the last few weeks has come to the point where I've just moved to Thunderbird today - I'm over it. I have no idea if Thunderbird is any good - but is sure can't be as bad as imap on mac mail.
After using Mac Mail since it came out, I am very dissapointed. Mac Mail is completely usuable with the fault.
OS 10.7.5 Mac Mail 5.3
You will find the solution on the Bell.net mail account. To make the life of Apple users difficult, Bell's default was to prevent POP users to access the Bell.net mail. However, they were nice enough to provide the option for users of POP to enable or disable this setting. Follow this procedure:
Log in to your Bell.net mail account
go to Managing your Account;
Go to the subdirectory Connect devices and apps with POP
Change the setting to Enable and Save
After I modified the setting, everything returned to normal in my case.
My particular version of this problem is that the Yahoo mail password in Ipad mail settings is periodically changed from the 10-character pwd I normally use to 8 characters. Oddly, this usually doesn't prevent yahoo mail from functioning both in Mail and in the Yahoo Mail app which I have also installed, but occasionally I receive a message that mail cannot be sent because the server is not recognized or some other failure notice, at which point I change the setting back to the correct password and mail functions correctly again. However, several days or weeks later, I find it is changed again from 10 to 8 characters.