Dovecot is an open-source IMAP, IMAP-SSL and POP3 server. It was written with security as one of its primary goals, and is flexible enough to work with just about any kind of back-end mailbox storage system, including vpopmail's folder structure. It also works with a large number of authentication back-ends, again including vpopmail. In this walkthrough we are only going to configure Dovecot 2 with IMAP-SSL and POP3-SSL and managesieve.

Dovecot will be using an unsecured connection. Having said that if Rainloop is communicating with Dovecot locally I don't believe this is a security issue.

The first step is to install Dovecot from ports.


# cd /usr/ports/mail/dovecot
# make install

When you run make install it will give you the various configure options available. Make sure the following options are checked:

DOCS
EXAMPLES
LIBWRAP
VPOPMAIL
GSSAPI_NONE

Configuring Dovecot

Dovecot itself uses the dovecot.conf for the main configuration file. What I am going to do here is provide a working dovecot.conf that has all options configured for you that use POP3D-SSL and also IMAPD-SSL for the most secure setup possible. Managesieve is enabled for filtering. Feel free to take a look at dovecot.conf before enabling dovecot.


# cd /usr/local/etc
# mv dovecot bak_dovecot
# mkdir dovecot
# cd dovecot
# tar zxvf ~root/qmail/dovecot2.tgz

If you would like to customize your hostname edit dovecot.conf and change the following line:


login_greeting = MAILHOST IMAP READY.

Now we need to edit the 10-ssl.conf file within the conf.d folder as seen below:


# cd conf.d
# vi 10-ssl.conf

In 10-ssl.conf only edit the ssl_cert and ssl_key. This will match the same filenames in the apache directory.


ssl_cert = </usr/local/etc/apache24/ssl.crt/domain.com.pem
ssl_key = </usr/local/etc/apache24/ssl.key/domain.com.key

Now lets create the dovecot service:


# mkdir /var/qmail/supervise/dovecot/log
# cd /var/qmail/supervise/dovecot/log
# cp ~root/qmail/service-any-log-run run
# chmod 0755 run
# vi run

In the run file change the second-to-last line to match the following:

multilog t n1024 s1048576 /var/log/qmail/dovecot \


# cd /var/qmail/supervise/dovecot/
# cp ~root/qmail/dovecot-run run
# chmod 0755 run

Now lets start the dovecot service:


# ln -s /var/qmail/supervise/dovecot /service/

Wait about ten seconds and then run the following command to make sure there are no issues:


# svstat /service/dovecot /service/dovecot/log

If you want easy access to dovecot logs I would suggest a symlink as follows just to make everything consistent:


# cd /var/log/qmail/
# cd dovecot
# ln -s /var/log/maillog maillog