Server Error: UID SORT: Internal error occurred.

Occasionally, Webmail users (Horde or Roundcube) on cPanel server may see the following error: Server Error: UID SORT: Internal error occurred. Inbox may not load at all.

It’s a permission issue which can be fixed by following command via Shell (root access is required):

/scripts/mailperm username

If it didn’t fix, please check mail log:

grep domain.tld /var/log/maillog

You should search for any errors associated with Dovecot imap. You may find something similar to: 

May 21 12:52:21 node.xxxxxxxxxxxxxx.com dovecot: imap([email protected])<22396><g0urpGOJiPhRtza0>: Error: Mailbox INBOX: UID=17245: read(/home/HASH/mail/domain.tld/email/cur/1547548534.M108213P371628.node.xxxxxxxxxxxxxx.com,S=7766,W=7934:2,S) failed: Cached message size larger than expected (7766 > 0, box=INBOX, UID=17245) (read reason=mail stream)

In this case, move the corrupted file:

mv /home/HASH/mail/domain.tld/email/cur/1547548534.M108213P371628.node.xxxxxxxxxxxxxx.com,S=7766,W=7934:2,S /home/HASH/mail/domain.tld/email/.Trash/cur/1547548534.M108213P371628.node.xxxxxxxxxxxxxx.com,S=7766,W=7934:2,S