Install Dovecot (Maildir)
Dovecot is a free and open source IMAP and POP3 server. This guide will setup Dovecot to use the Maildir format, pairing nicely with the OpenSMTPd Maildir guide. This guide will allow users to read mail with IMAP and POP.
Installation
Dovecot is third-party software available in [pkgadd/usage|packages]]:
# pkg_add dovecot--
This will install the flavor of dovecot without gssapi.
Configuration
In /etc/dovecot/dovecot.conf
, add the following lines at the bottom of the
file:
protocols = imap pop3 listen = 198.51.100.2, 2001:db8::2
Replace 198.51.100.2
and 2001:db8::2
with the server's actual public IP
addresses. This tells dovecot to listen to the protocols IMAP and POP3.
Note: Neither LMTP nor submission are required.
No changes need to be made to /etc/dovecot/conf.d/10-auth.conf
. By default,
the OpenBSD package will use the system
passwd(5) file for authentication.
In /etc/dovecot/conf.d/10-mail.conf
, add this line:
mail_location = maildir:%h/Maildir
This indicates to dovecot that all mail is stored in users' home folders,
~/Maildir
.
In /etc/dovecot/conf.d/10-ssl.conf
, change the following lines:
ssl = yes ... ssl_cert = </etc/ssl/example.com.crt ssl_key = </etc/ssl/private/example.com.key
Replace example.com
with the actual domain.
Dump non-default settings
Dovecot can dump all non-default settings. Verify that the non-default settings are similar to those listed below:
# dovecot -n # 2.3.21.1 (d492236fa0): /etc/dovecot/dovecot.conf # OS: OpenBSD 7.7 amd64 ffs # Hostname: example.com first_valid_uid = 1000 listen = 198.51.100.2, 2001:db8::2 mail_location = maildir:%h/Maildir mbox_write_locks = fcntl mmap_disable = yes namespace inbox { inbox = yes location = mailbox Drafts { special_use = \Drafts } mailbox Junk { special_use = \Junk } mailbox Sent { special_use = \Sent } mailbox "Sent Messages" { special_use = \Sent } mailbox Trash { special_use = \Trash } prefix = } passdb { driver = bsdauth } protocols = imap pop3 ssl_cert = </etc/ssl/example.com.crt ssl_key = # hidden, use -P to show it userdb { driver = passwd }
Login classes
After installation, the package will provide a README
in
/usr/local/share/doc/pkg-readmes/dovecot
.
Dovecot automatically adds a capability database in
/etc/login.conf.d/dovecot
:
dovecot:\ :openfiles-cur=1024:\ :openfiles-max=2048:\ :tc=daemon:
This login class gives dovecot special permissions. On a large server, it may be necessary to further increase the permissions. This can help if the server has many public IP addresses:
dovecot:\ :openfiles-cur=4096:\ :openfiles-max=8192:\ :tc=daemon:
See the login class guide for further information on login classes.
Starting dovecot
To start dovecot via rcctl:
# rcctl enable dovecot # rcctl start dovecot
Troubleshooting Dovecot
See the dovecot troubleshooting guide.