Icloud IMAP server "p01-imap.mail.me.com" rejected the password "XXXX." and The password is ok!. After several attempts to synchronize with them sometimes.
In my iPhone, I have a similar problem, although not as frequently happens
This works great for fixing the Mail app, but it doesn't play well with the iCloud system preferences, since the new account is not recognized as the same iCloud account-unchecking and checking the "Mail and Notes" box in the iCloud settings re-creates the same dysfunctional account settings. It seems like the easy fix would be to eliminate the pxx server designation in the auto settings so the app wouldn't constantly hang trying to communicate to an overloaded or non-functional mail server. Since the app works fine without it, I don't see the value of automatically assigning an email account to a specific server, especially for the user.