Reindex Dovecot Mailbox

Error type (mail.log)

  • FETCH [] for mailbox XXX UID XXXX got too little data: 0 vs 732242
  • Maildir filename has wrong W value XXXX
  • Corrupted index cache file /var/vmail/domain.com/user@domain.com/dovecot.index.cache: Broken virtual size for mail UID XXX

What is this script for

  • Find errors trought mail.log file.
  • Gets the real size of the error file and change the name with the right W value.
  • Rename corrupted file.

Sample Output

[+] File /var/vmail/domain.com/user@domain.com/cur/1348146749.M528940P710.mail,W=7322,S=7226:2,b.fake

[+] New count is: 5934

[*] moving file to: /var/vmail/domain.com/user@domain.com/cur/1348146749.M528940P710.mail,W=5934,S=7226:2,b.fake

[?] Ready... [press key]

[+] Backup file: /var/vmail/domain.com/user@domain.com/cur/1348146749.M528940P710.mail,W=7322,S=7226:2,b.fake.bkp

[+] File moved:

-rw-r--r-- 1 root root 0 Oct 2 15:58 /var/vmail/domain.com/user@domain.com/cur/1348146749.M528940P710.mail,W=5934,S=7226:2,b.fake


  • If you see something wrong, please drop me an email: jhonny5@riseup.net