diff --git a/content/blog/mail_server_alpine_postfix_dovecot_tutorial/index.md b/content/blog/mail_server_alpine_postfix_dovecot_tutorial/index.md index 23f8622..abf2292 100644 --- a/content/blog/mail_server_alpine_postfix_dovecot_tutorial/index.md +++ b/content/blog/mail_server_alpine_postfix_dovecot_tutorial/index.md @@ -507,6 +507,17 @@ Check the Dovecot version with: $ dovecot --version +Before you do anything, Dovecot requires that `dovecot_config_version` and `dovecot_storage_version` are the first +defined variables in `/etc/dovecot/dovecot.conf`. Edit this file and add, prior to any other settings, + +```conf +dovecot_config_version = 2.4.1 +dovecot_storage_version = 2.4.1 +``` + +Or whatever the output of `dovecot --version` is, though note that, if different, some of this guide may not apply to +your version of Dovecot. + Now let's enable IMAP by editing `/etc/dovecot/dovecot.conf`. Find a `protocols = ` line, or add one, and set it to: ```conf @@ -552,11 +563,23 @@ You should already have an `/etc/logrotate.d/dovecot` file. If not, create it wi You probably want to use the Maildir format for storing emails, where each user's mail is stored at `~/Maildir` (this can be set to another location if desired). -In `/etc/dovecot/conf.d/10-mail.conf`, set: +In `/etc/dovecot/conf.d/10-mail.conf`, in `namespace inbox` (or create the section if it does not exist): ```conf -mail_location = maildir:~/Maildir -mail_privileged_group = mail +namespace inbox { + mail_driver = maildir + mail_path = %{owner_home}/Maildir +} +``` + +If there is not already `inbox = yes` in the `inbox` namespace, add it: + +```conf +namespace inbox { + # ... + inbox = yes + # ... +} ``` `mail_privileged_group` tells us which group of Unix users can send mail; in this case, it's anyone in the `mail` @@ -573,7 +596,9 @@ To change the Maildir directory, e.g. to set it to `~/mail`, you would set the f `/etc/dovecot/conf.d/10-mail.conf`: ```conf -mail_location = maildir:~/mail +namespace inbox { + mail_path = %{owner_home}/mail +} ``` `/etc/postfix/main.cf`: @@ -615,19 +640,22 @@ smtputf8_enable = no ## Configuring authentication -Edit `/etc/dovecot/conf.d/10-auth.conf` and uncomment the following line: +Edit `/etc/dovecot/conf.d/10-auth.conf` and add the following line (or change it if the setting is set to `yes`): ```conf -disable_plaintext_auth = yes +auth_allow_cleartext = no ``` This disables plaintext authentication *unless* SSL/TLS is used. In the same file, configure `auth_username_format`. As the variable name suggests, this denotes the format the server -expects usernames in for authentication. Setting it to `%n` removes the domain, so to sign in to `user@domain.com` -you'd enter your username as `user`. For this setup, you should set `auth_username_format` to `%n`, because we are -using Unix user accounts for email accounts; Dovecot wouldn't be able to find `user@domain.com` because the mailbox -user is just `user`. +expects usernames in for authentication. Dovecot's variables have "filters" which can be chained with pipes. Say your +email address is `fred@domain.com`. This is the variable `%{user}`. We want to be able to log in with just `fred` as +our username. To do this, we apply the `username` filter, so we set + +```conf +auth_username_format = %{user | username} +``` In the same file again, `auth_mechanisms` is a space-separated list of authentication mechanisms your server uses. Set this to @@ -655,16 +683,20 @@ We will use a file at `/etc/dovecot/passwd` to manage this. Edit `/etc/dovecot/c the following: ```conf -passdb { +passdb passwd-file { driver = passwd-file - args = scheme=argon2id username_format=%n /etc/dovecot/passwd + auth_username_format = %{user | username} + default_password_scheme = argon2id + passwd_file_path = /etc/dovecot/passwd } -userdb { +userdb passwd-file { driver = passwd } ``` +Your `auth_username_format` should match the one you set in `/etc/dovecot/conf.d/10-auth.conf`. + See [this documentation](https://doc.dovecot.org/main/core/config/auth/schemes.html) to decide on a password scheme to use. I picked `argon2id` as the most secure option, however also the most expensive option, so it may be a poor option if you have many users. Dovecot recommends that, if using ARGON2ID, you set `vsz_limit = 2G` for the `auth` service. To @@ -722,16 +754,16 @@ just change their values): ```conf ssl = required -ssl_cert =