Frequently Asked Question
Use this when mail is missing in a client but files exist in the Maildir, or when phantom "1970 / no subject" messages appear that cannot be opened. Two indexes are involved: Dovecot's IMAP index (seen by IMAP/POP clients and webmail that talks IMAP) and Usermin's own folder cache (seen only inside Usermin's Mail module).
Replace user@domain.tld throughout with the affected mailbox address and user with the system username.
0. Identify the symptom
Messages show in a mail client but the underlying files are missing from /home/user/Maildir/cur and /home/user/Maildir/new.
Messages show with date 1 Jan 1970 and no subject, and cannot be opened.
Real messages exist in ~/Maildir/cur but do not appear in the client.
Stale or corrupted indexes are the usual cause. Run the relevant step below.
1. Confirm files actually exist for real mail
ls -la /home/user/Maildir
ls -la /home/user/Maildir/{cur,new,tmp} If real files are present but messages are missing from the client, re-index. If real files are missing, the index is correct and you have a delivery or client-side problem, not an index problem.
2. Re-index Dovecot (fixes IMAP clients and IMAP-backed webmail)
Dovecot stores its indexes centrally under /var/lib/dovecot-virtualmin/index (Virtualmin default). Rebuild from the real Maildir files using doveadm.
Re-sync a single mailbox:
doveadm force-resync -u user@domain.tld INBOX
Re-sync every mailbox for the user:
doveadm force-resync -u user@domain.tld "*"
No restart needed. Reconnect the client and check.
If force-resync does not clear stale entries, the central index directory for that user is corrupt. Stop Dovecot, move the per-user index directory aside, and restart:
systemctl stop dovecot mv /var/lib/dovecot-virtualmin/index/<user-index-dir> /var/lib/dovecot-virtualmin/index/<user-index-dir>.bak.$(date +%s) systemctl start dovecot
Dovecot rebuilds the index on next access. Confirm the user's mail is correct, then delete the .bak directory.
3. Re-index Usermin (fixes phantom messages inside Usermin only)
Usermin keeps its own per-user mail cache at ~/.usermin/mailbox with .byid.findex.pag / .byid.findex.dir DBM files. These can hold rows pointing at message files that were deleted. This cache is safe to remove; Usermin rebuilds it from the Maildir on next login.
systemctl stop usermin mv /home/user/.usermin/mailbox /home/user/.usermin/mailbox.bak.$(date +%s) systemctl start usermin
Have the user log back into Usermin. The mailbox list rebuilds from real files; ghost entries disappear. Confirm, then remove the .bak directory.
4. Useful doveadm commands (Dovecot 2.3)
Inspect an index without altering it. List messages Dovecot currently knows about for a mailbox:
doveadm fetch -u user@domain.tld "uid date.received hdr.subject" mailbox INBOX
Show resolved mail location and home for a user (useful if force-resync does not behave as expected):
doveadm user user@domain.tld doveconf -n | grep -E 'mail_location|mail_home|mail_uid'
5. When to use which
Real files missing from Maildir but shown by client: nothing to re-index; investigate delivery (Postfix logs /var/log/maillog) and disk (df -h, df -i).
Real files present, client shows nothing: re-index Dovecot (step 2). If the only client affected is Usermin, also do step 3.
Phantom 1970 / no-subject messages, files absent everywhere: re-index Usermin (step 3). If IMAP clients also show them, re-index Dovecot too (step 2).
6. Safety notes
Always mv the cache or index directory to a .bak suffix rather than rm first. Delete only after confirming the mailbox looks correct in the client.
Re-syncing while a user has an active IMAP session is fine; Dovecot handles it. For Usermin, stop the service first to avoid concurrent writes to the cache.
Index rebuilds only affect cached metadata, never the real messages in ~/Maildir. No mail is lost by re-indexing.
