How to force Dovecot to reindex raw email files?
Usually, Dovecot is very good at recognizing broken mailboxes and fixes issue on its own. Anyway, doveadm force-resync
can be used to reindex in this very case.
Anyway, you should rather use doveadm import
to copy those mails back into Dovecot instead of directly fiddling with Dovecot's mailbox folders, even if using MailDir: it will prevent wrong indexes from the beginning.