imap-maildir: production quality UW-imap server Maildir support

drh.net

David Harris, dharris@

Posted June 19, 1999.
Updated February 22, 2000.

Available for consulting work

I am currently available for consulting work. For consulting, I am happy to telecommute or come to your site for a period of time.

For more information about my skills and experience, view my statement of consulting capabilities or contact me for more information.

Quick Summary
Unless you have a specific need to continue using UW-IMAP, this patch is obseleted by the deveopment of better IMAP servers like courier-imap, dovecot, and bincimap.

The University of Washington IMAP server by Mark Crispin, one of the most popular IMAP servers, does not have built-in Maildir support. There is a patch which adds in a Maildir driver, but it falls short of a workable solution in a few ways. This page details a few patches which clean up a few issues and make the UW-IMAP server fully workable with Maildirs and qmail.

Looking for a new maintainer for these patches!!
I'm looking to find someone else to maintain these patches. I created these patches for my own personal use and then placed them online for the community to benefit. I'm no longer actually using the patches anymore and can't find the time to perform the maintenance and support that they need. If you are interested in maintaining the patches, e-mail me. Thanks!


Make sure to see the important updates section below.

Did your installation stop sorting messages correctly on 9 Sep 2001 01:46:40 GMT? Find the fix to the 10-digit unix date rollover problem in the important updates section below.

Back to davideous.com home.


1. Description

There are two main problems with using the current Maildir support patch with the University of Washington IMAP server:
  1. New folders are created as Mbox folders, not Maildir folders.
  2. Moving mail between Mbox folders and Maildir folders causes an error because the code in the Maildir driver to move messages between folders of different formats (which I understand is a substantial chunk of work) was never written.
These two problems lead to a server setup where one can not move mail from the INBOX to any other user-created folders. This basically prevents the UW IMAP server from being used in a production environment with Maildirs.

However, I have created two patches which sit on top of the Maildir driver patch in the UW-IMAP server which, in my opinion, make Maildir support workable.

The patches simply commit the user to only using Maildir folders. This way the driver inadequacy of not being able to move messages between different-type folders is simply never felt. If you don't mind committing to Maildirs, then this should work for you in a production environment.

Here are the patches that I created:

  • imap-4.5-createproto.patch
    This causes new folders to be created as Maildirs if the user's INBOX folder is a Maildir. Otherwise the folders are created as the system default of Mbox folders.

  • imap-4.5-mdirlist.patch
    If the user's INBOX folder is a Maildir, then when the client uses the IMAP LIST command to list all the possible folders, we only call the Maildir driver's list method. This helps prevent the user from opening any non-Maildir folders which may exist. In addition, the Mbox driver list method recursively shows every single file in the user's home directory as a possible mailbox, so this patch is also good because it gets rid of all that clutter. Which can be quite a bit if you have lots of messages in the Maildirs.

  • imap-4.5-maildir980721-rename.patch
    This fixes a bug in the maildir driver which prevented Maildir folders from being renamed.

  • imap-4.5-maildir980721-delete.patch
    This fixes a bug in the maildir driver which did not fully delete Maildir folders.

I also use the following patch which someone else (I don't know who) created:
  • imap-4.5-qmail.patch
    This causes the Mbox driver to look for the INBOX in the standard qmail location of ~/Mailbox instead of in the system mail spool (which is /var/spool/mail/$USER on my system). The Maildir driver naturally looks in the standard qmail location of ~/Maildir.
Of course, all this is in addition to the Maildir driver patch.


2. Distribution & Installation

Note on version numbers
These patches were originally build for UW-IMAP sever version 4.5, but they have been successfully applied to versions 4.6 and 4.7a without any modification. As of late, I have been too busy try these myself or to create a new RPM file for the new versions.

2.1 Build your own from scratch

Grab the UW-IMAP server v4.5:

Grab and apply the maildir patch: NOTE: The patch above was origionally at "http://www.freeit.com/mta/maildir980721.patch.gz" (that site is now gone), but I had some problems applying their patch to the IMAP server source tree and had to hand-apply some of it. So you don't have to go through the same trouble, I re-made their patch to cleanly apply to the imap-4.5.tar.Z source tree. However, note that this is still THEIR WORK, just in a different format produced by me. (The extension drhfu stands for drh fix up.)

Now apply this patch:

Now apply the following patches: Then build the server. (Here is some help using the patch command.)

2.2 Use my pre-patched source tree

Some people have trouble or don't want to bother with all of those patches, so here is a pre-patched source tree that contains all of the patches above:

The above source tree is missing the following patch: 2.3 Use my RPM

This RPM is the imap-4.5-3 RPM that came with RedHat Linux 6.0 with the above patches applied. It is a drop-in replacement for the RPM which ships with RedHat. I don't know if this will work on non RedHat-based Linux systems, but you are free to give it a try.

The version number and revision are a little weird on this. When you see imap-4.5-3mdir3 think imap-4.5-3 maildir patch three.

Also, if you are developing any applications which use the IMAP client libraries (such as PHP3) then you will want the following RPM, which has those library files you need:

Also, if you build an RPM for another architecture, please send me a copy so I can post it here.

Note for RedHat 5.x users
As I understand it, most RPM's built on a RedHat 6.0 system, as these are, do not work on a RedHat 5.x system. However, may be possible to download the source RPM and re-build on a 5.x system using the --rebuild flag. Please let me know if this works for you.


Important updates

Lacking time to update the above text (which refers to older versions of UW-IMAP), I've resorted to placing updates in this section.

Imap-4.7 & Red Hat 6.2 RPM update

In the distrib/imap-4.7 directory you will find updated patches and files for imap-4.7. David Summers has also created an RPM file for Red Hat 6.2 and the imap-4.7 server that you an also find in that directory. Be sure to read the README to know what everything is!

I apologize for not having the time to properly update this site and change all of the links above.


New patch for Imap-2000c

This is a port of all my patches for the UW-IMAP server imap-2000c found here.

Important links:

Thanks to Herbie for updating the patches for the latest UW-IMAP version.


10-digit unix date rollover problem

On 9 Sep 2001 01:46:40 GMT the UNIX time_t value hit one billion and thereby all new dates sort before all the previous time_t values. This causes problems with the sorting routine in the imap-maildir code. Use this patch to fix your existing installations:

Thanks to Bob Harris for the C code.


New patch for UW Imap-2004c1

From Wai-leng LEE, leewaileng <at> ctimail3 <dot> com:

I had written a maildir patch for the newest version of UM-Imap 
2004c1.  It is developed by referring to Herbie's patch.  The maildir.c 
and maildir.h is completely the same as Herbie's one.  I'd already 
tested it with qmail-1.03 using maildir on Redhat 7.3 system.  Attached 
with the patch for you to put on http://www.davideous.com/imap-maildir/


3. Change log

Here is a changelog of the updates to this page and these patches:

September 10, 2001

  • Added 10-digit unix date rollover patch. Thanks to Bob Harris. Also Philip Guenther and Daniel Morriss and Ross Bennett.
February 28, 2001
  • Added updated patches for UW-IMAP server imap-2000c from Herbie.
July 18, 2000
  • Added imap-4.7 patch files and the David Summers RPM to the distrib directory and a note on the site pointing to them.
February 22, 2000
  • Added note about these patches for version 4.5 still working just fine for versions 4.6 and 4.7a.
December 02, 1999
  • Added note about imap-4.5_maildirpatched-1.00.tar.gz file which already has existed for a while.
August 26, 1999
  • Added new RPM which has the imap-devel sub-package and also has the imap-4.5-man.patch which corrects a typo on the man pages.
August 17, 1999
  • Added the imap-4.5-maildir980721-delete.patch
  • New rpm files with this patch.
  • Added note for RedHat 5.x users about RPM usage.
June 27, 1999
  • Added the imap-4.5-maildir980721-rename.patch
  • New rpm files with this patch.
June 19, 1999
  • First posting.