qmail-cyrus howto by Jason van Zyl

  This page used to be at
but all I get there is an four-o-four error. But in September 2000 a user posted a cached copy of this document from Google to
. (See
. And now I do provide a retrieved copy of this how to over here.

Jason van Zyl
16 Jun 1999
$Id: qmail-cyrus.html.php,v 1.1 2001/07/25 16:28:26 dekarl Exp $


This document is a simple outline of how to get qmail to work cooperatively
with the Cyrus IMAP server. 

This document is based on a version of the Cyrus IMAP server that has been
patched to authenticate from a CDB database. The method outlined should work
with other authentication mechanisms, but I have only tested the method with
CDB authentication. I figured why use a closed-system IMAP server and
then have to add entries to /etc/passwd.

Some other notes of caution: the setup is RedHat centric, I've made two
RPMS, a cyrus RPM and qmail RPM, that I use to set the system up. Also I
only have 40 people who need mail in my organization so I have no idea how
well the system would hold up under a load. If there was any sort of
bottle neck it would be with the scripts that I have written to bridge Cyrus
and qmail. 

The first problem I will try to rememdy by making a tarball
of the Cyrus package, the patch that I've made to authenticate via a CDB
file, and the bridge scripts. There really isn't that much to it, and really
you could probably get a system working with the standard Cyrus/qmail
tarballs and the bridge scripts provided here. It's just that the scripts
all have hard-coded paths in them because the RPM puts them where I use
them. I would eventually like to make a little configure script with
autoconf that would do all the path substitution but I haven't done that
yet. So be warned, all the scripts included have hard-coded paths. The RPM
spec file which encapsulates all the building and installation instructions
is just a shell script so I will try to turn it into a little stand-alone
installation script.

This document assumes that you have a pretty good understanding
of how qmail works.

Here's a basic description of how the system works, I have scripts to
automate all this, but I figure it's good to show how things are done

Delivery of mail from qmail to Cyrus

For each user, place an entry in the users/assign file like so:


This tells us that qmail will look at the .qmail file in /mail/cyrus/imap to
find out how to deliver mail to jvanzyl@compusense.com.

Here's what that .qmail file looks like:

|/mail/cyrus/imap/qmail_deliver_wrapper $LOCAL

This little line contains a reference to a script that will do some parsing
of $LOCAL (where in this case $LOCAL = compusense-com-jvanzyl), try to
the mail to the users Cyrus mailbox, and translate Cyrus' exit codes to
exit codes so that qmail is happy.

Using the RPMS

Right now the RPMS work on a RedHat 5.2 system. I compiled the RPMS on 5.2
system but I have used the RPMS on a 5.1 system. The RPMS will probably work
on a 6.0 system, but I'm not sure if they would compile. I've been having
glibc 2.1 problems, for some unknown reason glibc 2.1 moved around standard
header files. They must have had a reason but it doesn't make compiling my
standard RPMS very much fun.

If you use the RPMS on a 5.1/5.2 system you should have no problems. There's
a bunch of scripts for adding users, archiving, and testing the system.

But you'll have to make your own inetd/tcpupsi entries because I use xinetd
for all my servers.

Files of note in the RPMS


The default .qmail has two lines:

|/mail/cyrus/imap/qmail_deliver_wrapper $LOCAL
|/mail/cyrus/imap/qmail_deliver_wrapper ${LOCAL}_archive

The first one is normal, but the second is for placing a copy of the message
in an archive mailbox. As mentioned before I don't have a lot of users so
this isn't very expensive for me. But possibly not something you want to do
at a larger organization. Just remove the second line if you don't want



This is used to add the administrator, normal user mailboxes along with
the corresponding users/assign entry, and archive mailboxes.


1. This tells the system what the cyrus administrators username and password
   are. No mailbox is created.

   add_mailuser --username=cyradm --password=cyradm --cyradm

2. This tells the system that the user jvanzyl has the password jvanzyl. The
   users.jvanzyl mailbox is also created.

   add_mailuser --username=jvanzyl --password=jvanzyl

3. This tells the system to add an archive mailbox for the user jvanzyl. It
   is called users.jvanzyl_archive. You still have to put in the --password
   parameter. I have to fix the script.

   add_mailuser --username=jvanzyl --password=jvanzyl --archive



This just takes a username and password and does 2. & 3. above.



Called by add_mailuser to build the CDB file that cyrus uses for



Called by add_mailuser to create Cyrus IMAP mailboxes. It's basically
a little chat script using expect. I would like to replace with a perl
script that sends IMAP commands directly to the server. Then you don't need
Tcl, which I'm not very fond of.



This is the command used in the cyrus .qmail file to deliver mail from qmail
to cyrus.



Script to test a users mailbox to make sure it's functioning properly.


test_deliver jvanzyl@compusense.com



Script to test all users' mailboxes to make sure they're functioning

Some problems

I have found that aliasing users is a little cumbersome. Say I want ngenner
to get mail for jvanzyl: I have to remove the entry for jvanzyl in
users/assign and create a .qmail file in the qmail/alias directory. As I've
mentioned before I don't have many users to deal with so this doesn't happen
that often.

Maybe the fastforward package might be better.

Or I was thinking of making a mechanism that would take care of aliasing
within the qmail_deliver_wrapper script with a slight alteration of the
users/assign entry. Consider the folling line:


This would indicate to the qmail_deliver_wrapper to shunt all mail for
jvanzyl to ngenner. This would work for internal users, but is not so
elegant for bumping mail back to the outside world. I supposed you could
qmail-inject it but that seems kind of silly.

Anyway, these are just ideas right now.

Future plans

I would like to make an LDAP authentication mechanism for Cyrus. I've heard
that there's a qmail-LDAP package somewhere, but I'm not exactly sure what
it does. I like LDAP because Samba will also use LDAP. I'm actually trying
to make a system where there is a *universal* user. I enter them once in the
LDAP system and presto they have mail, news, can login from Linux, can login
from Windows machines. Right now I have to change things in too many places
and doesn't make for a very consistent system. 

I would also like to make Cyrus use Maildirs! Then I would have to do any of
this mail delivery funny business! I've only glanced at the source and it
possible but I haven't started anything in earnest.

VERSION: 2.1rc1
 Known Bugs
 Links & References


 Search interface
 Adding entries


 Y2K proof?
 Mailing List
 URL format
 URLs in entries
 LDAP errors

 SF.net Project

Test it:
 TU Chemnitz
 TU Chemnitz CGI
 Other sites

hosted by sourceforge
  (qmail-cyrus.html.php Version 1.1) last modified by dekarl on 2001/07/25 at 16:28:26 GMT