Post Office

Dovecot

Dovecot 2.4 (e.g. Debian 13) uses a configuration syntax which is incompatible with Dovecot 2.3 (e.g. Debian 12 or Ubuntu 24.04). Example configurations for both versions are included in ./mailserver/dovecot/ . Check your version with dovecot --version .

Both configurations are put into /etc/dovecot/local.conf , which is read after all other configuration files, so the default configuration files of your distribution can stay mostly untouched.

Step by Step

  1. Disable the authentication against system users by commenting out the following line in /etc/dovecot/conf.d/10-auth.conf :

    #!include auth-system.conf.ext
  2. Dovecot 2.4 only: Debian strips the domain from the username when Dovecot receives emails from Postfix. Comment out the following line in the section protocol lmtp of /etc/dovecot/conf.d/20-lmtp.conf :

    #auth_username_format = %{user | username | lower}

    local.conf overrides this setting anyway, but otherwise doveconf keeps warning about it.

  3. Copy the configuration file(s) for your version of Dovecot.

    # Dovecot 2.4
    sudo cp ./mailserver/dovecot/2.4/local.conf /etc/dovecot/local.conf
    sudo chmod 600 /etc/dovecot/local.conf
    
    # Dovecot 2.3
    sudo cp ./mailserver/dovecot/2.3/local.conf ./mailserver/dovecot/2.3/local-sql.conf.ext /etc/dovecot/
    sudo chown root:dovecot /etc/dovecot/local-sql.conf.ext
    sudo chmod 640 /etc/dovecot/local-sql.conf.ext
  4. Replace all placeholders in square brackets:

    [IP4] and [IP6]
    The public IP addresses of your mail server.
    [DOMAIN]
    The domain the TLS certificate was obtained for, as in /etc/letsencrypt/live/[DOMAIN]/ .
    [POSTMASTER_EMAIL]
    The email address used as sender for bounces generated by Dovecot, e.g. postmaster@example.com .
    [FIRST_VALID_UID]
    The user ID of the system user vmail (see id vmail ). Dovecot refuses to access mailboxes with a lower user ID.
    [PASSWORD]
    The password of the database user vmail (in local-sql.conf.ext for Dovecot 2.3).
  5. If you don't use Rspamd, remove the "Spam Training" sections (Dovecot 2.4: sieve_script learn-spam and imapsieve_from INBOX.Junk , Dovecot 2.3: all imapsieve_mailbox* settings).
  6. Check the configuration and restart Dovecot.

    sudo doveconf -n > /dev/null
    sudo systemctl restart dovecot

Authentication

Dovecot checks the passwords of all users, also on behalf of Postfix. The Post Office stores passwords as bcrypt hashes, which Dovecot knows as BLF-CRYPT . Mailboxes can log in to all services, while send-only addresses can only log in to Postfix for sending emails. Disabled accounts can't log in at all.

Dovecot 2.4:

passdb sql {
    default_password_scheme = BLF-CRYPT
    query = SELECT username, domain, password, CONCAT(quota, 'M') AS userdb_quota_storage_size \
        FROM accounts \
        WHERE username = '%{user | username}' AND domain = '%{user | domain}' AND password IS NOT NULL AND enabled = true \
        AND (type = 'mailbox' OR (type = 'sendonly' AND '%{protocol}' = 'smtp'))
}

Dovecot 2.3:

default_pass_scheme = BLF-CRYPT
password_query = SELECT username,domain,password,CONCAT('*:storage=',quota,'M') AS userdb_quota_rule FROM accounts WHERE username='%Ln' AND domain='%Ld' AND password IS NOT NULL AND enabled=true AND (type='mailbox' OR (type='sendonly' AND '%s'='smtp'));

Users log in with their full email address, which is converted to lowercase.

Quota

The storage quota of each mailbox is set in the Post Office in megabytes. A quota of 0 means unlimited storage. Dovecot reads the quota from the database on every login and delivery, so changes take effect immediately. Users can see their quota usage in IMAP clients which support it.

To check the quota usage of a mailbox:

sudo doveadm quota get -u john@example.com

Mail Storage

Emails are stored in Maildir format in /var/mail/virtual/DOMAIN/USERNAME/mailbox/ . All folders are subfolders of the inbox, separated by dots (e.g. INBOX.Sent ). The folders "Drafts", "Sent", "Junk" and "Trash" are created and subscribed automatically.

Sieve Filters

Users can manage their own Sieve filters (e.g. for vacation notices) with any ManageSieve client on port 4190, e.g. the Thunderbird add-on "Sieve" or the managesieve plugin of Roundcube. Their filters are stored in /var/mail/virtual/DOMAIN/USERNAME/sieve/ .

Before the users' filters, the global filter /var/mail/virtual/default/sieve/spam-global.sieve moves emails which were marked as spam into the folder "Junk".

Search results