How to Fix Dovecot Quota Warning Error
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
- Placing the wildcard pattern first in case expressions, making all subsequent patterns unreachable
- Using
headandtailinstead of pattern matching, causing runtime errors on empty lists - 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
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro