By default, Plesk and the Courier-IMAP email server drastically limit the number of inbound connections to prevent users from opening up too many concurrent sessions. Unfortunately, this restriction can impact legitimate users who have multiple computers connecting to the Courier-IMAP server from behind a firewall or a single computer that runs an IMAP client that takes advantage of mailbox caching.
This article applies to you if you are seeing this message when accessing your email:
ERROR:
Unable to connect to your IMAP server.
You may have exceeded the maximum number of connections to this server.
READ ME FIRST
This article is provided as a courtesy. Installing, configuring, and troubleshooting third-party applications is outside the scope of support provided by (mt) Media Temple. Please take a moment to review the Statement of Support.
Instructions
Plesk comes configured with a limit of 4 connections per IP address and a limit of 40 connections total. Modern IMAP clients such as Mozilla Thunderbird use mailbox caching to open up multiple connections to increase performance. In the case of Thunderbird, it opens up 5 connections by default which is already 1 connection more than Courier-IMAP’s default restriction. Add another few computers behind a firewall and those additional users won’t be able to connect at all since a single Thunderbird client is already utilizing all 4 connections.
To increase this restriction you can modify your IMAP configuration file located at /etc/courier-imap/imapd using the following Perl commands which perform a "find and replace":
perl -p -i -e 's/^MAXDAEMONS=40/MAXDAEMONS=80/g' /etc/courier-imap/imapd
perl -p -i -e 's/^MAXPERIP=4/MAXPERIP=40/g' /etc/courier-imap/imapd
Then to complete the changes restart the courier-IMAP service using the following commands:
/etc/init.d/courier-imap stop
/etc/init.d/courier-imap start
The above commands change MAXDAEMONS from 40 to 80 and MAXPERIP from 4 to 40, thus allowing for many machines behind a firewall to connect to multiple accounts on the email server with mailbox caching enabled.
But even those numbers may be too low for a corporate server that services an entire company. Tweak those numbers based on your employee base; if 50 employees are connecting to the email server from behind the same firewall then MAXPERIP could need to go as high as 250 (50 employees x 5 cached mailbox connections). Add email clients of people working from home and MAXDAEMONS could go as high as 300 or 400!
Obviously, the connection limits are to prevent the Courier-IMAP server from using too much memory and/or CPU resources on the machine. Tweak the numbers based on the (dv) service that you have and it’s available memory resources. If you are still receiving this error after making these changes, you might want to consider other ways to reduce usage or possibly upgrading your service.