How can I raise Courier-IMAP or POP3 connections for my server?


Browse by products and services

  • Applies to: All DV
    • Difficulty: Medium
    • Time Needed: 10
    • Tools Required: SSH, root access, vi knowledge

Overview

By default, Plesk's Courier-IMAP and POP3 email servers 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 theserver from behind a firewall or a single computer that takes advantage of mailbox caching.

This article applies to you if you are seeing a message such as this when accessing your email:

ERROR:
Unable to connect to your IMAP server.
You may have exceeded the maximum number of connections to this server.

Requirements

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 both a limit of connections per IP address and an overall limit of Courier-IMAP and POP3 connections. Modern IMAP and POP3 clients such as Mozilla Thunderbird use mailbox caching to open up multiple connections to increase performance. As an example of this, Thunderbird 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, depending on your IMAP configuration, those additional may not be able to connect at all since a single Thunderbird client is already utilizing all connections.

The below 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.

IMAP

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

If you will be using POP3 as well, you should run the following commands to make the same changes. If not, skip down to the bottom code box to restart your Courier-IMAP service.

POP3

To increase this restriction you can modify your POP3 configuration file located at /etc/courier-imap/pop3d using the following Perl commands which perform a "find and replace":


perl -p -i -e 's/^MAXDAEMONS=40/MAXDAEMONS=80/g' /etc/courier-imap/pop3d
perl -p -i -e 's/^MAXPERIP=4/MAXPERIP=40/g' /etc/courier-imap/pop3d

Then to complete the changes restart the services using the following commands:


/etc/init.d/courier-imap stop
/etc/init.d/courier-imap start

/etc/init.d/courier-pop3d stop
/etc/init.d/courier-pop3d start

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 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.