Mac OS X Mail app and Courier IMAP(-ssl) problems

If you have an IMAP server based on Courier-IMAP and you get complains from people using the default on Mac OS X about getting many warning messages and not being able to connect, the remedy is to increase the maximum allowed concurrent sessions per IP. They possibly have multiple accounts on the server and is not able to handle each connection properly.
The cure is to open up /etc/courier-imap/imapd-ssl and /etc/courier-imap/imapd, find the MAXPERIP setting and change it to something like:

Don’t forget to restart your courier-imap server for changes to take effect.

By default the MAXPERIP setting is set to 4. On the imapd-ssl file it’s not even included in the config file (but still set to 4) so you need to add it yourself.