sawyl: (Default)
sawyl ([personal profile] sawyl) wrote2007-05-02 09:37 pm
Entry tags:

Dovecot on NetBSD

Here's a quick guide to getting the dovecot IMAP server work on NetBSD, using CRAM-MD5 passwords so that things work with Apple Mail.

1. Build and Install dovecot Build and install the package in the normal way:

cd /usr/pkgsrc/mail/dovecot
make install

2. Set up the Configuration
Set up the configuration files:

touch /usr/pkg/etc/dovecot.conf
touch /usr/pkg/etc/dovecot-cram-md5.pwd
chmod 0600 /usr/pkg/etc/dovecot.conf
chmod 0600 /usr/pkg/etc/dovecot-cram-md5.pwd

3. Edit dovecot.conf
The main configuration file should contain something like the following:

base_dir = /var/run/
login_dir = /var/run/login

protocols = imap
ssl_disable = yes
login_chroot = no
login_user = dovecot
default_mail_env = maildir:/home/%u/.Maildir

auth_verbose = yes
auth_debug = no

auth default {
mechanisms = cram-md5

passdb passwd-file {
args = /usr/pkg/etc/dovecot-cram-md5.pwd
}


userdb passwd {
}
user = root
}

4. Set up the passwords file
Create an encrypted password entry using the following bit of magic:

echo foo:`/usr/pkg/sbin/dovecotpw` >> /usr/pkg/etc/dovecot-cram-md5.pwd

Replacing "foo" with a sensible user name. If you're using sudo (and if you're not, what's wrong with you?), you'll need to do the following:

sudo sh -c "echo foo:`/usr/pkg/sbin/dovecotpw` >> /usr/pkg/etc/dovecot-cram-md5.pwd"

5. Set up the Startup Script
Set up the rc script in the usual way:

cd /etc/rc.d
cp /usr/pkg/share/examples/rc.d/dovecot .

6. Start the Server
Start the server by hand in the usual way:

/etc/rc.d/dovecot forcestart

If everything's good, you can tweak rc.conf to start the server at boot.