Dovecot quota do not match mail directory size

Discussion in 'ISPConfig 3 Priority Support' started by JaapV, Mar 11, 2023.

  1. JaapV

    JaapV New Member HowtoForge Supporter

    Hi,
    Lately, I get complaints from people that use our ISPConfig mailserver (v 3.2.9p1) that although they deleted mails from their mailbox, new incoming mail is still refused. I'm not sure, but it seems to be only happening with users who've already hit the quota limit.
    Todays example:
    11:11 User sends me a message that new mail does not arrive.
    14:30 (It's weekend) I check why. I assume he cleaned out his over-quota mailbox before he send me a mail, because when I check the directory it is down to 6,5G and the user as a 7G quotum. ISPConfig still shows 100% full for this user.
    Mail should arrive now, so I send a test message. This bounces with message:
    Quota exceeded (mailbox for user is full)
    When I run doveadm quota recalc -A, this seems to solve the problem. ISPConfig now shows 93% and the second test mail I send is accepted.
    So recalculating the quota manually seems to work, but Dovecot should do this when new mail arrives, right?

    Has anyone seen similar problems before?

    Could this be a misconfiguration in dovecot? My installation has been upgraded from a very ancient ISPConfig with a stone-age Debian and Courier mail to where we are now, so maybe some configuration file has been missed.
     
  2. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    Can you share your Dovecot configuration?
     
  3. JaapV

    JaapV New Member HowtoForge Supporter

    This is dovecot.conf
    Code:
    # Do not change this file, as changes will be overwritten by any ISPConfig update.
    # Put your custom settings in /usr/local/ispconfig/server/conf-custom/install/dovecot_custom.conf.master.
    # To start using those changes, do a force upgrade and let it reconfigure your services. (ispconfig_update.sh --force)
    listen = *,[::]
    protocols = imap pop3 lmtp
    auth_mechanisms = plain login
    disable_plaintext_auth = no
    log_timestamp = "%Y-%m-%d %H:%M:%S "
    mail_privileged_group = vmail
    ssl_cert = </etc/postfix/smtpd.cert
    ssl_key = </etc/postfix/smtpd.key
    ssl_dh = </etc/dovecot/dh.pem
    ssl_min_protocol = TLSv1.2
    ssl_cipher_list = ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384
    ssl_prefer_server_ciphers = no
    mail_max_userip_connections = 100
    mail_plugins = quota
    passdb {
      args = /etc/dovecot/dovecot-sql.conf
      driver = sql
    }
    userdb {
      driver = prefetch
    }
    userdb {
      args = /etc/dovecot/dovecot-sql.conf
      driver = sql
    }
    plugin {
      quota = dict:user::file:/var/vmail/%d/%n/.quotausage
    
      # no longer needed, as 'sieve' is in userdb extra fields:
      sieve=/var/vmail/%d/%n/.sieve
    
      sieve_before=/var/vmail/%d/%n/.ispconfig-before.sieve
      sieve_after=/var/vmail/%d/%n/.ispconfig.sieve
      sieve_max_script_size = 2M
      sieve_max_actions = 100
      sieve_max_redirects = 25
    }
    service auth {
      unix_listener /var/spool/postfix/private/auth {
        group = postfix
        mode = 0660
        user = postfix
      }
      unix_listener auth-userdb {
        group = vmail
        mode = 0600
        user = vmail
      }
      user = root
    }
    service lmtp {
      unix_listener /var/spool/postfix/private/dovecot-lmtp {
       group = postfix
       mode = 0600
       user = postfix
       # For higher volume sites, it may be desirable to increase the number of active listener processes.
       # A range of 5 to 20 is probably good for most sites
    #   process_min_avail = 5
      }
    }
    lmtp_rcpt_check_quota = yes
    service imap-login {
      client_limit = 1000
      process_limit = 512
    }
    protocol imap {
      mail_plugins = $mail_plugins quota imap_quota
      auth_verbose = yes
    }
    protocol pop3 {
      pop3_uidl_format = %08Xu%08Xv
      mail_plugins = $mail_plugins quota
      auth_verbose = yes
    }
    protocol lda {
    postmaster_address = [email protected]
      mail_plugins = $mail_plugins sieve quota
    }
    protocol lmtp {
    postmaster_address = [email protected]
      mail_plugins = $mail_plugins quota sieve
    }
    
    service stats {
        unix_listener stats-reader {
            user = vmail
            group = vmail
            mode = 0660
        }
    
        unix_listener stats-writer {
            user = vmail
            group = vmail
            mode = 0660
        }
    }
    
    service quota-status {
      executable = quota-status -p postfix
      unix_listener /var/spool/postfix/private/quota-status {
        group = postfix
        mode = 0660
        user = postfix
      }
      client_limit = 1
    }
    plugin {
      quota_status_success = DUNNO
      quota_status_nouser = DUNNO
      quota_status_overquota = "552 5.2.2 Mailbox is full"
    }
    
    imap_capability=+SPECIAL-USE XLIST
    namespace inbox {
      inbox = yes
      separator = .
      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
      }
    }
    
    !include_try conf.d/99-ispconfig-custom-config.conf
    
    And this is 99-ispconfig-custom-config.conf:
    Code:
    #
    ssl_cert = </etc/postfix/smtpd.cert
    ssl_key = </etc/postfix/smtpd.key
    
    protocol imap {
      mail_plugins = imap_sieve
    }
    
    plugin {
      sieve_plugins = sieve_imapsieve sieve_extprograms
    
      # From elsewhere to Spam folder
      imapsieve_mailbox1_name = Junk
      imapsieve_mailbox1_causes = COPY
      imapsieve_mailbox1_before = file:/etc/dovecot/rspamd/rspamd-learn-spam.sieve
    
      # From Spam folder to elsewhere
      imapsieve_mailbox2_name = *
      imapsieve_mailbox2_from = Junk
      imapsieve_mailbox2_causes = COPY
      imapsieve_mailbox2_before = file:/etc/dovecot/rspamd/rspamd-learn-ham.sieve
    
      sieve_pipe_bin_dir = /etc/dovecot/rspamd
    
      sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
    }
    
     
  4. Th0m

    Th0m ISPConfig Developer Staff Member ISPConfig Developer

    This is most likely the problem. You have specified a plugin for protocol imap, that overwrites what we set in the ISPConfig config. Change your custom config for the imap protocol to this:
    Code:
    protocol imap {
      mail_plugins = $mail_plugins quota imap_quota imap_sieve
    }
    
    And restart Dovecot. I think that fixes it.

    Remember to change the template in conf-custom and copy that to 99-ispconfig-custom-conf.conf, then restart Dovecot.
     
  5. JaapV

    JaapV New Member HowtoForge Supporter

    Thanks, I will try that.
     
  6. JaapV

    JaapV New Member HowtoForge Supporter

    I didn't see anything bad in the log files until now (a few hours after changing the configuration) so I assume everything still works. No idea why this line was not the default, but as I said, this server has lived through many configuration changes already.

    Normally I would like to report back when a problem is solved, but in this case, when it's solved, nobody will complain about not receiving emails after deleting their over-quota mail. So let's consider the problem solved and if not, I'll get back to you.

    Thank you for your support!
     
    Th0m likes this.

Share This Page