Running a home IMAP server on Ubuntu
I tend to work from several locations, and I like having access to my mail folders from everywhere. Some of my mail comes from POP accounts, but I also have access to an IMAP server. For a while, I used to store “active” conversations on the IMAP server, and periodically archive them in the mbox folders at home to stay within my alloted mail quota. This meant that if I wanted to look at an older message, I basically had to ssh to my home box and dig it out.
I finally got tired of moving e-mails back and forth and decided to set up an IMAP server on my home box. Which server to use? I’ve been using mbox folders for a long time and wasn’t about to convert to Maildir, which ruled out Courier. After a bit of searching, I found UW IMAP. I’ve always been a fan of pine, so I tend to trust mail software from the University of Washington.
An apt-get install uw-imapd later, I was faced with a server that installs no configuration files in /etc and no service script in /etc/init.d. The latter puzzle was easy to solve: UW-IMAP expects to be called from inetd or xinetd and conveniently appends to /etc/inetd.conf, so apt-get install inetd is enough to enable this service. I fired up Thunderbird, and defined a new IMAP account; Thunderbird was able to connect, but authentication failed.
I next turned to the IMAP FAQ, and found out that UW-IMAP prides itself on needing no configuration; meaning that, if you need to change things like the user’s mail directory (which annoyingly defaults to the user’s home and exports the entire directory tree), you have to recompile the package.
I also learned that, in fact, there is one configuration file: /etc/cram-md5.pwd, to be filled with usernames and passwords (one pair per row, tab-separated). Since I did not install the IMAP SSL package, cram-md5 is the only way to retain some security, otherwise passwords are sent in clear over the network. Thunderbird has an option to force CRAM MD5 authentication in the account settings dialog.
I was finally able to connect to the IMAP server, but now the folder list included every file in my home directory, since, as I mentioned, UW-IMAP’s idea of the mail store is the user’s entire home. To solve this, you can use “mail” as an IMAP server path (Server settings > Advanced in Thunderbird).
But some programs don’t have this option or ignore the setting (Opera’s M2 seems to do that). Another solution involves a hack; create a dummy user (say joe-mail if your login is joe) with the same UID and GID as the real user, and with a home directory in the desired location:
id joe # your login name # note the uid and gid, then sudo useradd -u $uid -g $gid -d /home/joe/mail joe-mail
After updating /etc/cram-md5.pwd and Thunderbird, I was finally able to read mail from my home IMAP server. UW-IMAP has some counter-intuitive defaults, but, once you know what to do, is quite easy to tweak.
Update: apparently, dovecot-imapd (recommended by two readers) and cyrus-imapd might be easier to set up, but I’ve already spent enough time tending to UW-IMAP, so I’m not touching it. Feel free to comment if you have used other servers.

Dovecot seems to be the current favorite, and it is easy to secure with SSL.
Comment by patrick giagnocavo — January 17, 2007 @ 10:34 pm
I’ve been using dovecot. Works a treat. Performance is great. I’ve never been able to get UW-IMAP to work properly. Cyrus was a real pain to set up, to the point where I eventually gave up. Dovecot was my third attempt, and I’ve never looked back.
Comment by Ted Lemon — January 17, 2007 @ 11:37 pm
Thanks, Patrick and Ted. I’ve updated the article to mention dovecot.
Comment by Dan Muresan — January 18, 2007 @ 4:41 am
I’ll add one more vote for Dovecot. Having used the other available daemons at one time or another, Dovecot is refreshingly simple and solid - perhaps simply by the virtue of it not yet having had the time to accumulate all the crufty layers that cover the others?
PS. Migration from UW-IMAP is covered in the Dovecot wiki.
Comment by Arto Bendiken — January 22, 2007 @ 9:41 am
I run Dovecot 1.0.rc2 on Ubuntu Edgy and I am afraid I would not recommend it in a production environment. When SSL is enabled, connections with Dovecot usually time out as soon as multiple operations are performed (ex= moving a group of emails from one directory to another), or when emails with large attachments are involved. Dovecot also seem to have difficulties handling lock files and again times out very often (I have not tried without SSL). Finally, it does not handle IMAP subdirectories, which requires console intervention when created.
I hope these issues are fixed in newer releases (1.0.rc27 as this time).
Comment by Romain Wartel — March 20, 2007 @ 7:20 am