bengreen.eu Circle Device

 

Quick Reference

Dovecot setup with xmail

Dovecot with xmail

I use http://xmailserver.org but I have a number of requirements for imap access... for that I tried courier which is great except that it does not play well with outlook 2010.

Download and Build

To begin, download the sources, configure and make:

./configure --prefix=/opt/dovecot --with-sqlite
make

You will need the sqlite development files installed to perform the configure and compilation.

Configuration

Copy all the default configuration:

cd /opt/dovecot
cp -r share/doc/dovecot/example-config/* etc/dovecot

Add a group and a user for dovecot:

groupadd dovecot
useradd --home-dir /var/empty --shell /bin/false --gid dovecot dovecot

In my case I decided to disable imap, pop3 and pop3s... I don't use them:

file: 10-master.conf
default_login_user = nobody
default_internal_user = dovecot

service imap-login {
  inet_listener imap {
    port = 0
  }
  inet_listener imaps {
    port = 993
    ssl = yes
  }
}

service pop3-login {
  inet_listener {
    port = 0
  }
  inet_listener {
    port = 0
  }
}

Alter the 10-ssl.conf file and add the appropriate files, you will need a key a certificate and a dh.pem (dh params file). The comments in the config file are very helpful.

ssl = yes
ssl_cert = </opt/dovecot/bengreen_eu.cert
ssl_key = </opt/dovecot/bengreen_eu.key
ssl_dh = </opt/dovecot/dh.pem

Configure SQL Authentication

Edit the 10-auth.conf file, at the end enable sql authentication:

!include auth-sql.conf.ext

This is also the place to set the default authentication mecanism (see the link in references for more on this).

Change the paths for passdb and userdb in the etc/dovecot/conf.d/auth-sql.conf.ext file so that they are correct. They should be pointing to the dovecot-sql.conf.ext file we will edit next.

Then, dovecot-sql.conf.ext:

driver = sqlite
connect = /opt/dovecot/user.db
default_pass_scheme = PLAIN
password_query = \
  SELECT id AS username, password FROM user WHERE id = '%u'
user_query = \
  SELECT home, uid, gid FROM user WHERE id = '%u'

Then you should make a database file with sqlite and insert some rows:

CREATE TABLE user ( id TEXT, password TEXT, home TEXT,
  uid INTEGER, gid INTEGER, PRIMARY KEY ( id ) ) ;

An example entry might be:

INSERT INTO user VALUES (
  'ben@example.com',
  '{SHA512-CRYPT}$6$xjjE7RGwNjBf0562$m1InWS7qrY/uT6jeKm2L5rclT5gU2yzH9z3Y.qv2ov0mJw2fAKEsThyM8CDeHuOjUe3QhHtT8GxJyOksh0FEa0',
  '/home/ben',
  1000,
  100 );

Running the service

As we have opted to put all the executables and config into /opt/dovecot we have to add some things to the path in order to allow the main dovecot process to spawn helpers.

export PATH=/opt/dovecot/sbin:/opt/dovecot/libexec:$PATH
dovecot

To see what is going on look into your syslog output.

Reference

Quick Links: Techie Stuff | General | Personal | Quick Reference