Symptoms
You are unable to sync your IMAP mail client with the messages on the server, and an error similar to the following can be found in the /var/log/maillog
file.
Aug 9 16:08:01 vm dovecot[819714]: imap($user@$domain.tld)<843370><BOpq+ngCxcbdhSeK>: Error: Mailbox INBOX: Deleting corrupted cache record uid=4468: UID 4468: Broken virtual size in mailbox INBOX: read(/home/$cpuser/mail/$domain.tld/$user/cur/1690338101.M660983P1721.server.domain.tld,S=503136,W=510358:2,S): FETCH BODY[] got too little data: 31080 vs 510358
Description
This issue occurs when one or more messages in the user's mailbox are corrupt. The corruption can be identified by comparing the file size in bytes to the S
value in the email message's file name. In the following example, the S=503136
portion of the file name indicates that the file should be 503,136 bytes, but the file size on the disk is only 30,387 bytes.
[root@server ~]cPs# stat /home/$cpuser/mail/$domain.tld/$user/cur/1690338101.M660983P1721.server.domain.tld,S=503136,W=510358:2,S
File: /home/$cpuser/mail/$domain.tld/$user/cur/1690338101.M660983P1721.server.domain.tld,S=503136,W=510358:2,S
Size: 30387 Blocks: 64 IO Block: 4096 regular file
Device: fd00h/64768d Inode: 171875105 Links: 1
Access: (0640/-rw-r-----) Uid: ( 1002/$cpuser) Gid: ( 1004/$cpuser)
Access: 2023-08-09 15:26:11.860306807 +0800
Modify: 2022-10-19 09:49:18.780000000 +0800
Change: 2023-08-09 15:07:02.786848340 +0800
Birth: 2023-08-08 15:19:47.226832607 +0800
[root@server ~]cPs#
Workaround
The corrupt file must be removed or restored from a backup.
Additional resources
How to restore missing emails from a backup within the command line
How to manually locate and extract a file or directory from a cPanel backup