Skip to content

How to Fix Dovecot Quota Warning Error

DodaTech Updated 2026-06-24 2 min read

In this tutorial, you'll learn about How to Fix Dovecot Quota Warning Error. We cover key concepts, practical examples, and best practices.

Dovecot does not send quota warning emails when users exceed their mailbox limits — the quota plugin is not configured or the warning script is not executable.

The Problem

$ doveadm quota get -u user@example.com
Quota name Type Value Limit %
User quota STORAGE 512000 1024000 50
# User goes over quota but no warning email is sent

Step-by-Step Fix

Step 1: Enable quota plugin

# /etc/dovecot/dovecot.conf
mail_plugins = $mail_plugins quota

protocol imap {
    mail_plugins = $mail_plugins imap_quota
}

Step 2: Configure quota limits

# /etc/dovecot/conf.d/90-quota.conf
plugin {
    quota = maildir:User quota
    quota_rule = *:storage=1GB
    quota_rule2 = Trash:storage=100MB
    quota_warning = storage=95%% quota-warning 95 %u
    quota_warning2 = storage=100%% quota-warning 100 %u
}

Step 3: Create quota warning script

sudo mkdir -p /etc/dovecot/quota-warning.sh
#!/bin/bash
PERCENT=$1
USER=$2

cat << EOF | /usr/sbin/sendmail -t
To: $USER
Subject: Mailbox quota warning ($PERCENT% full)

Your mailbox is currently $PERCENT% full.
Please delete some emails to avoid being blocked from sending.

Best regards,
Mail Administrator
EOF

Step 4: Make script executable

sudo chmod +x /etc/dovecot/quota-warning.sh
sudo chown root:root /etc/dovecot/quota-warning.sh

Step 5: Configure quota warning service

# /etc/dovecot/conf.d/90-quota.conf
service quota-warning {
    executable = script /etc/dovecot/quota-warning.sh
    user = dovecot
    unix_listener quota-warning {
        user = vmail
        group = vmail
        mode = 0660
    }
}

Step 6: Test quota warning

sudo doveadm quota recalc -u user@example.com
sudo doveadm quota get -u user@example.com

Prevention Tips

  • Send warnings at 80%, 90%, and 100% usage levels
  • Test the quota warning script manually before deploying
  • Monitor quota usage with doveadm quota
  • Use multiple warning thresholds for gradual alerts

Common Mistakes with quota warning

  1. Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
  2. Using head and tail instead of pattern matching, causing runtime errors on empty lists
  3. Forgetting that lazy evaluation defers computation until the value is forced, causing space leaks with unevaluated thunks

These mistakes appear frequently in real-world DOVECOT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Why does Dovecot not send quota warning emails?

The quota warning service is not configured or the script is not executable. Ensure quota_warning directives are set in 90-quota.conf and the warning script has execute permissions. Test the script manually: sudo /etc/dovecot/quota-warning.sh 95 user@example.com.

How do I set different quota limits for different users?

Use user-specific quota rules in the database. With LDAP or SQL passdb, return the quota_rule field per user. For static rules, use quota_rule = *:storage=1G for all users and override specific users in the user database.

What is the difference between quota_warning and quota_warning2?

You can define multiple warning thresholds using numbered directives: quota_warning, quota_warning2, quota_warning3, etc. Each triggers at different usage levels. For example, 80%, 90%, and 100% thresholds with different warning messages.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro