Having your own mail server can be a great experience. If you are hosting your own mail server with Courier-IMAP, you might have trouble connecting with more than one computer at the same time. I had that trouble and found the solution in the configuration file.
With my Mail application running on my desktop machine, my laptop would not connect to the server. It looked like there were SSL problems on my laptop, but it turned out not to be so. Later, I noticed that if my laptop was already connected to the mail server, my desktop machine could not connect. The message from Mail was a little misleading. It appeared that there was a problem connecting to the server because of a problem with the SSL certificate or some other SSL issue.
After a little digging around in the Courier-IMAP configuration file, I found a line that limited the maximum number of connections from the same IP address.
In a FreeBSD server, that configuration file is:
/usr/local/etc/courier-imap/imapd
I solved the problem by changing the configuration file for Courier-IMAP. Since my desktop and my laptop share the same IP, I had to tell the IMAPD configuration file that I wanted more connections from the same IP address.
The default setting was:
MAXPERIP=4
I changed it to:
MAXPERIP=8
I am not sure how many connections each computer made, but when I went from one computer to two, the default setting of 4 didn’t work. So, I doubled it, restarted the mail server and connected from two computers simultaneously.
My problem disappeared. So if you are having trouble connecting with more than one computer, try changing the MAXPERIP number to something higher. And realize that if you are connecting from a network that shares a single IP address, multiple computers will need multiple connections from the same IP address, and this needs to be managed in the imapd configuration file.
EDIT: I recently changed the number of connections to 60:
MAXPERIP=60
By observing the netstat (with this command: systat -netstat), the first computer logged in with 4 connections, the second with 5 connections. It all depends on the e-mail client and how many connections it opens simultaneously. Since I am hosting more e-mail addresses and logging in with more devices, I gave myself some room. The server is doing just fine handling all the e-mail requests.
If you have multiple people checking e-mail from behind a single firewall (a single IP address), you may want to change this setting to something more like 5 * [number of users]. For example, 10 users could easily use up 50 connections, 100 users could cause 500 connections to be made from one IP.
To restart courier-imap on a FreeBSD 7 machine, use these two commands:
/usr/local/etc/rc.d/courier-imap-imapd restart
/usr/local/etc/rc.d/courier-imap-imapd-ssl restart
That’s it. No more trouble with multiple computers checking into your courier-imap mail server. These examples are from FreeBSD 7, with courier-imap installed from the ports collection.
I highly recommend this book: “Building a Server With FreeBSD 7″ by Bryan J. Hong. I have two posts related to it:

