Recovering a Full Mailbox on a Plesk / Dovecot Server
A step-by-step command-line tutorial for system administrators. This guide covers diagnosing a mailbox that has hit its quota (the classic "Mailbox full (#4.2.2)" SMTP bounce), safely reclaiming space without destroying user data, and preventing the problem from recurring.
Contents
- Why "Mailbox Full" Happens
- Step 1 - Diagnose the Mailbox
- Step 2 - Safe Cleanup (Trash and Spam)
- Step 3 - Redundant Sent and Drafts Folders
- Step 4 - Clearing Mailer-Daemon Bounces
- Step 5 - The Gmail "All Mail" Trap
- Step 6 - The Real Fix: Inbox Size
- Step 7 - Raising the Quota
- Command Cheat Sheet
1. Why "Mailbox Full" Happens
On a Plesk server, mail is stored on disk but indexed and quota-tracked by Dovecot. Even if the underlying MTA is qmail or Postfix, Dovecot is what enforces the per-mailbox quota. When usage crosses 100%, the SMTP server refuses new deliveries with a 451 4.2.2 Mailbox full response, and may also refuse to send mail, because sent copies are written to the sender's own mailbox.
The most common pattern is a long-lived account (for example an executive mailbox or an info@ address) that has accumulated tens of thousands of messages in INBOX, plus several redundant folders created by IMAP clients over years of server migrations.
2. Step 1 - Diagnose the Mailbox
All commands below are run as root over SSH. Replace user@example.com with the mailbox you are investigating. Every one of them uses doveadm, the official Dovecot administration tool. Never delete files directly from /var/qmail/mailnames/, as this corrupts the Dovecot index.
2.1 Check the current quota
doveadm quota get -u user@example.com
Example output:
Quota name Type Value Limit %
user STORAGE 15643428 10485760 149
user MESSAGE 116796 - 0
STORAGE is in kilobytes by default. A value above Limit means the mailbox is over quota. A percentage above 100 confirms it.
2.2 List every folder with its message count
doveadm mailbox status -u user@example.com messages vsize mailbox '*' 2>/dev/null | sort -t= -k2 -n -r
This shows each folder and how many messages it holds. Look for the biggest folders, usually INBOX, a [Gmail].All Mail folder, and several duplicate Sent folders.
2.3 Find the true on-disk size per folder
doveadm message counts do not always reflect disk usage. To see actual bytes:
du -sh /var/qmail/mailnames/example.com/user/Maildir/.INBOX* 2>/dev/null | sort -h
This is read-only and completely safe.
3. Step 2 - Safe Cleanup (Trash and Spam)
Trash and spam folders are by definition disposable. Purging them is zero-risk and should be the first action.
doveadm expunge -u user@example.com mailbox INBOX.Trash all
doveadm expunge -u user@example.com mailbox "INBOX.[Gmail].Trash" all
doveadm expunge -u user@example.com mailbox INBOX.INBOX-Trash all
doveadm expunge -u user@example.com mailbox INBOX.Spam all
doveadm expunge -u user@example.com mailbox "INBOX.[Gmail].Spam" all
doveadm expunge -u user@example.com mailbox INBOX.INBOX-Spam all
Run only the lines whose folders actually exist. Check with:
doveadm mailbox list -u user@example.com
Re-check the quota afterwards:
doveadm quota get -u user@example.com
Note: If the folder name contains spaces or special characters such as [ or ], always quote it, for example: mailbox "INBOX.[Gmail].Spam".
4. Step 3 - Redundant Sent and Drafts Folders
After several server migrations, an IMAP client often re-creates "Sent" under a new name each time. The result is a mailbox with five Sent folders and two Drafts folders, all containing overlapping copies of the same messages. This is a classic signature and a large, safe win.
4.1 Identify the duplicates
for f in INBOX.Sent INBOX.INBOX-Sent "INBOX.Sent Items" "INBOX.INBOX-Sent Items" INBOX.sent-mail "INBOX.INBOX-sent-mail" INBOX.Drafts INBOX.INBOX-Drafts; do
echo "== $f =="
doveadm mailbox status -u user@example.com messages "$f" 2>/dev/null
done
4.2 Rename (reversible) - do not delete yet
Renaming is the safe first move: it proves no client is still actively using the folder. Wait three to seven days, then purge.
doveadm mailbox rename -u user@example.com INBOX.INBOX-Sent INBOX.OLD-INBOX-Sent
doveadm mailbox rename -u user@example.com "INBOX.INBOX-Sent Items" "INBOX.OLD-INBOX-Sent-Items"
doveadm mailbox rename -u user@example.com INBOX.sent-mail INBOX.OLD-sent-mail
doveadm mailbox rename -u user@example.com INBOX.INBOX-sent-mail INBOX.OLD-INBOX-sent-mail
doveadm mailbox rename -u user@example.com INBOX.INBOX-Drafts INBOX.OLD-INBOX-Drafts
4.3 Roll back if a client complains
doveadm mailbox rename -u user@example.com INBOX.OLD-INBOX-Sent INBOX.INBOX-Sent
4.4 Purge the renamed folders after the waiting period
doveadm expunge -u user@example.com mailbox INBOX.OLD-INBOX-Sent all
doveadm expunge -u user@example.com mailbox "INBOX.OLD-INBOX-Sent-Items" all
doveadm expunge -u user@example.com mailbox INBOX.OLD-sent-mail all
doveadm expunge -u user@example.com mailbox INBOX.OLD-INBOX-sent-mail all
doveadm expunge -u user@example.com mailbox INBOX.OLD-INBOX-Drafts all
5. Step 4 - Clearing Mailer-Daemon Bounces
A mailbox that sends to stale addresses accumulates hundreds or thousands of "Undelivered Mail Returned to Sender" messages. These are safe to purge but should be identified before they are deleted.
5.1 Count first
doveadm search -u user@example.com mailbox INBOX subject "Undelivered Mail" | wc -l
doveadm search -u user@example.com mailbox INBOX from "MAILER-DAEMON" | wc -l
5.2 Purge if the counts are large
doveadm expunge -u user@example.com mailbox INBOX subject "Undelivered Mail"
doveadm expunge -u user@example.com mailbox INBOX from "MAILER-DAEMON"
Warning: Bounces are a symptom, not the disease. If you find thousands of them, check whether the account is being abused to send to scraped lists. See Step 6.
6. Step 5 - The Gmail "All Mail" Trap
Critical: If a mailbox is connected to a Gmail account via IMAP, INBOX.[Gmail].All Mail is not a copy, it is the physical storage of every message. Deleting it permanently wipes the user's Gmail history. The same applies to INBOX.[Gmail].Important and INBOX.[Gmail].Starred, which are labels pointing at those same messages.
Before touching any [Gmail] folder, determine whether the account is still synced:
- Ask the user, or check Plesk's mail client configuration for the mailbox.
- If it is not synced, meaning the [Gmail] folders are leftovers from a past migration, they are stale duplicates and can be purged safely.
- If it is synced, do not delete them. Ask the user to clean up in the Gmail web interface; deletions made there will sync down, freeing space on the server.
7. Step 6 - The Real Fix: Inbox Size
Once trash, spam, redundant Sent folders, and bounces are gone, the mailbox is usually still dominated by one folder: INBOX. A fifty-thousand-message inbox will refill any quota. Two options remain.
Option A - Archive old mail off-server (correct fix, needs user consent)
# 1. Full snapshot of INBOX to a local maildir (read-only)
mkdir -p /root/archives/user-inbox
doveadm backup -u user@example.com maildir:/root/archives/user-inbox
# 2. Verify the snapshot looks sane
find /root/archives/user-inbox -type f | wc -l
# 3. Only after confirming the backup and getting sign-off:
doveadm expunge -u user@example.com mailbox INBOX savedbefore 1y
savedbefore 1y deletes messages older than one year. Other time suffixes: d for days, w for weeks, mon for months, y for years. Use savedon or senton for exact-date operators.
Option B - Raise the quota (band-aid)
See Step 7. It stops the bleeding for weeks or months but does not fix the fifty-thousand-message inbox.
Find out what is filling the inbox
doveadm fetch -u user@example.com "hdr" mailbox INBOX | grep -i "^From:" | sort | uniq -c | sort -rn | head -20
If one sender dominates, that is the leak. Add a Sieve rule to auto-file or discard it.
8. Step 7 - Raising the Quota via Plesk
Check disk space before raising anything:
df -h /var/qmail
Then update the mailbox quota (value in megabytes):
plesk bin mail --update user@example.com -mailbox_quota 20480
Verify with:
doveadm quota get -u user@example.com
Note: plesk bin mail --update changes both the Plesk-side and the Dovecot-side quota. If you only change Dovecot's configuration, Plesk will overwrite it on the next sync.
9. Command Cheat Sheet
| Task | Command |
|---|---|
| Show quota | doveadm quota get -u user@example.com |
| List folders | doveadm mailbox list -u user@example.com |
| List folders with message counts | doveadm mailbox status -u user@example.com messages vsize mailbox '*' |
| Empty a folder | doveadm expunge -u user@example.com mailbox FOLDER all |
| Delete mail older than one year | doveadm expunge -u user@example.com mailbox FOLDER savedbefore 1y |
| Rename a folder | doveadm mailbox rename -u user@example.com OLDNAME NEWNAME |
| Create a folder | doveadm mailbox create -u user@example.com FOLDER |
| Search by subject | doveadm search -u user@example.com mailbox FOLDER subject "STRING" |
| Search by sender | doveadm search -u user@example.com mailbox FOLDER from "ADDRESS" |
| Snapshot a mailbox to disk | doveadm backup -u user@example.com maildir:/path/to/backup |
| Raise quota (Plesk) | plesk bin mail --update user@example.com -mailbox_quota 20480 |
Plesk Dedicated Servers are provided by Systron Dedicated Server Hosting — high-performance bare-metal servers with full Plesk control panel, root access, and DDoS-protected infrastructure.