I have the same error and a similar set of circumstances.
I have two iCloud accounts in Mail. When Mail tries to connect with one of them ([username]@icloud.com), it asks me to put in my password. When I put it in, I get a new error message: This Mac can't connect to iCloud because of a problem with '[username]@icloud.com'. Open iCloud preferences to fix this problem.
When I open iCloud preferences it is not evident what I am supposed to do to fix the problem.
Because I don't use either iCloud account, I selected the single iCloud account that both e-mail addresses (one @icloud.com, the other @mac.com) are connected to and deselected Mail. Then I restarted my computer. Then I deleted the two accounts from Mail. No problem.
But unfortunately, the next time I restarted my computer and then opened Mail, both of those accounts were back. According to iCloud preferences, I am not syncing Mail with my iCloud account. When I tried to delete the two accounts from Mail again I got the same error that meglizwake got.
One more thing: to suppress the error messages, I deselected "Enable this account" from the preferences for each iCloud account in Mail. Unfortunately, when I quit Mail and then launch it again, the two accounts are enabled again, and the error messages resume.
Lastly, this started when I upgraded to Mavericks.