Dovecot not serving all messages through IMAP

Solution 1:

Broken Indexes and Other Mailbox Issues

This sounds like an issue with a broken mailbox index, which is something Dovecot's usually very good at fixing on its own. In case it fails, you can force Dovecot to repair indexes and other issues using

doveadm force-resync -u <username> <mailbox>

in case of the user johndoe and mails not showing up in his inbox, the command would be

doveadm force-resync -u johndoe INBOX

Running doveadm -Dv force-resync ... (debug and verbose output) might provide more insight on any issues.

Client Side Issues

In rare cases, mail clients might suffer under inconsistent local data, especially when mails have been renumbered on the server side due to mailbox issues. Some mail clients know "repair" functions, other might require you to remove and recreate the mailbox and thus trigger a full sync.