Revision of Dovecot from Wed, 06/03/2009 - 14:35

Revisions allow you to track differences between multiple versions of your content, and revert back to older versions.

Dovecot is an open source IMAP and POP3 server for Linux/UNIX-like systems, written with security primarily in mind. Dovecot is an excellent choice for both small and large installations. It's fast, simple to set up, requires no special administration and it uses very little memory.

Installation
Download the latest tarball of the Dovecot source:

cd /extra/src
wget http://dovecot.org/releases/1.1/dovecot-1.1.5.tar.gz
tar zxf dovecot-1.1.5.tar.gz
cd dovecot-1.1.5

Configure Dovecot with support for vpopmail, compile and install it. If you want POP3 as well as IMAP, you need to specify it in the configure options.

./configure --with-vpopmail --with-pop3d
make
make install

Create a user and group for Dovecot to run as:

groupadd dovecot
useradd -g dovecot -s /bin/false -c "Dovecot Mail Server" dovecot

Configuration
Dovecot has installed a /usr/local/etc/dovecot-example.conf file, which you'll have to rename to /usr/local/etc/dovecot.conf:

cp /usr/local/etc/dovecot-example.conf /usr/local/etc/dovecot.conf

Authentication
To enable authentication with vpopmail, edit /usr/local/etc/dovecot.conf and uncomment:

# vpopmail authentication <doc/wiki/AuthDatabase.VPopMail.txt>
  passdb vpopmail {
    # [cache_key=<key>] - See cache_key in PAM for explanation.
    #args =
  }

  # vpopmail <doc/wiki/AuthDatabase.VPopMail.txt>
  userdb vpopmail {
  }

You'll also want to make sure that pam is disabled in /usr/local/etc/dovecot.conf:

# passdb pam {
....
#}

Since the vpopmail user is uid 89, we need to adjust a few more settings in /usr/local/etc/dovecot.conf:

first_valid_uid = 89
last_valid_uid = 89

Courier by default uses "INBOX." as the IMAP namespace for private mailboxes. Configuring Dovecot the same way can make things easier when configuring clients and also when switching existing Maildirs from Courier to Dovecot. There are two ways to accomplish this:

  • Using the same INBOX. namespace as Courier. With this method, Mail.app (at least in OS X 10.3) required that you specify INBOX as the IMAP Path Prefix when configuring the account.

    namespace private {
      separator = .
      prefix = INBOX.
      inbox = yes
    }
  • Create the INBOX. as a compatibility name, so old clients can continue using it while new clients will use the empty prefix namespace.
    namespace private {
      separator = .
      prefix = INBOX.
      inbox = yes
    }

    namespace private {
      separator = .
      prefix = INBOX.
      inbox = no
      hidden = yes
      list = no   # for v1.1+
    }

Self-Signed SSL Certificate
Dovecot by default does not allow plain-text logins so you'll need to have an SSL certificate for it use. You can use Dovecot's instructions or you can create a self-signed certificate using the Apache SSL instructions. If you do it the Apache way, copy the certificates to a location where we'll configure Dovecot to read it from:

cd ~/cert
cat server.key server.crt > /usr/local/etc/dovecot.pem

Then modify /usr/local/etc/dovecot.conf to find the files:

ssl_cert_file = /usr/local/etc/dovecot.pem
ssl_key_file = /usr/local/etc/dovecot.pem

However, if you did need to use plaintext auth with Dovecot, you can modify /usr/local/etc/dovecot.conf to allow it. Please, don't let users connect over the Internet like this though!

disable_plaintext_auth = no

Daemontools Startup
The DJB Way website has a page on running Dovecot through daemontools. These instructions are adapted from that.
Firstly, create a directory to hold the service:

mkdir -m 1755 /var/service/dovecot-imapd
mkdir -m 755 /var/service/dovecot-imapd/log
cd /var/service/dovecot-imapd

Then create the /var/service/dovecot-imapd/run file with the following contents:

#!/bin/sh
# dovecot-imapd/run
# daemontools run script for dovecot-imapd service
# ===
exec 2>&1
echo "*** Starting dovecot-imapd service..."
exec envuidgid dovecot \
    /usr/local/sbin/dovecot \
    -F \
    -c /usr/local/etc/dovecot.conf

Make the run script executable and then set up the logging service:

chmod 755 run
cd log
wget http://qmail.jms1.net/scripts/service-any-log-run
mv service-any-log-run run
chmod 755 run

Edit /usr/local/etc/dovecot.conf so that it sends log messages to /dev/stderr where multilog can catch them.

log_path = /dev/stderr

Make the symbolic link in /service to start Dovecot:

ln -s /var/service/dovecot-imapd /service/dovecot-imapd

After about 10 seconds, confirm that it is running:

svstat /service/dovecot-imapd /service/dovecot-imapd/log

Courier to Dovecot migration
In general, there's not really much you need to do to migrate existing Maildirs from Couier-IMAP to Dovecot. However, one thing I did notice was that folder subscriptions do not copy from Courier's Maildir/courierimapsubscribed file to Dovecot's Maildir/subscriptions file. Depending on your mail client, this might not be an issue. Mail.app, for instance, picked up the new folders even though they weren't listed in Maildir/subscriptions. On the other hand, SquirrelMail didn't see them unless you manually subscribed to them.

The Dovecot wiki has a wiki Courier migration page has some migration details that have an impact for POP3 users and has a Courier-to-Dovecot migration script to take of some POP3 UIDL issues. The script also can convert Courier's Maildir/courierimapsubscribed file to Dovecot's Maildir/subscriptions format (basically removing "INBOX." from the entries).

cd /usr/local/bin
wget http://www.dovecot.org/tools/courier-dovecot-migrate.pl
chmod ugo+x courier-dovecot-migrate.pl
cd /home/vpopmail/domains/<domain>
/usr/local/bin/courier-dovecot-migrate.pl --recursive --convert --overwrite

Recent Updates

  • 1 year 12 months ago
  • 1 year 12 months ago
  • 1 year 12 months ago
    php 8.x
  • 1 year 12 months ago
    10.6.7
  • 2 years 19 hours ago
    Drop Centos 5/6 stuff