Dovecot and vmailmgr (and qmail)

The dovecot IMAP server does not support VMailMGR out of the box. This page helps you getting them to work together.
Send feedback to mij@bitchx.it.

Flavours

I mantained an old version that required patching dovecot and an overall more complicated process for installation. Since v1.2rc6, however, dovecot supports colon characters in mailboxes, used by VMailMgr. Since then, the process is much easier and requires only a simple wrapper.

Summary

Dovecot supports authentication via checkpassword interface. VMailMGR summarily implements such interface, but requires minor adjustments. You use a wrapper for doing such adjustments and interfacing vmailmgr properly with dovecot.

This is how you do it:

  1. you install dovecot normally
  2. you download the vmailmgr-to-dovecot wrapper
  3. you compile and install the wrapper (as root):
    cc -Wall -O2 -o checkvpw-dovecot-wrapper checkvpw-dovecot-wrapper.c
    install -s -o root checkvpw-dovecot-wrapper /usr/local/bin
    
    note: the wrapper expects the vmailmgr authenticator at /usr/local/bin/checkvpw. If you have it elsewhere, change the CHECKVPW_BINARY_PATH constant defined in it.
  4. you configure dovecot to authenticate through the wrapper. Make these changes to dovecot.conf:
    [..]
    mail_location = maildir:%h
    [..]
    auth default {
        mechanism = plain
        passdb checkpassword {
            args = /usr/local/bin/checkvpw-dovecot-wrapper
        }
        userdb prefetch {
        }
        user = root
    }
    
  5. you restart dovecot and enjoy.
    note: if you need logging for troubleshooting, uncomment the definitions of the LOGINIT() and LOG() macros in checkvpw-dovecot-wrapper.c and recompile/reinstall it. Use auth_debug_passwords=yes in dovecot.conf.

Technicalities

The wrapper runs the actual VMailMGR authenticator checkvpw, collects its result (OK/KO, mailbox and user/group IDs), and formats them for input back in dovecot.

VMailMGR makes /home/domain.com/users/name:surname the mailbox for user name.surname@domain.com. Dovecot uses colons as internal field separators; however, since v1.2rc6, it allows colons occurrences via escaping (as :::). Before passing such mailbox paths to dovecot, the wrapper performs such escaping.