I set-up dovecot as mail pic-up server for IMAP and POP3. If I left my webmail(roundcube) interface running on my browser, I experienced very often that as soon as I started an Apple mail product (iPad,iPhone or Mail on OSX the IMAP complained that my login failed and asked for typing my password. Normally the passowrd was stored in my keychain and should not be needed to be typed that way. Even after typing the password again I could not login any more. To fix this temporarily though I had to login with ssh on the server and restart dovecot daemon process. This happened for a long time, I searched the Net for solutions to this. It’s only after quite a while that I found some setting of dovecot which might help with this, although the explanation of its porposes doesn’t suggest that it could be the solution at all.

The setting in /etc/dovecot/dovecot.conf is as follows:
# Maximum number of IMAP connections allowed for a user from each IP address.
# NOTE: The username is compared case-sensitively.
mail_max_userip_connections = 1000

I set it to quite high value (1000) just to make sure. It might not really need to be that high though.
After I set-up this new value my problem with IMAP login stopped.