0

I accidentally lost all my e-mails except for those in the inbox folder while changing the server configuration. I can still see the entire history of the mail server in the mbox file but I can't seem to figure out how can I retrieve all those email into the IMAP server.

I've read up on mbox specification and there doesn't seem to be any mechanism that would indicate that the e-mail has been moved by the IMAP server to a folder. I deleted the ~/mail directory, renamed the mbox file, restarted each time but the Dovecot still somehow knows which messages inside the mbox file have been moved and which haven't. I still can see the trash folder and it still has the messages that have been moved there.

How can I make the Dovecot forget all the data it has stored about this mbox file and reload it whole unsorted into the inbox folder, as if it was a new installation of the server?

1 Answer 1

1

I've read up on mbox specification and there doesn't seem to be any mechanism that would indicate that the e-mail has been moved by the IMAP server to a folder.

When a message is moved to a folder, it is literally moved to a new mbox file corresponding to that folder and deleted from the original mbox file.

Though the deletion is two-step – first the original message is marked with the D flag for \Deleted, and then sometime later it is expunged from the folder. So it could very well be that your IMAP client just hides messages marked for deletion.

Check whether the messages have Status: D (or Status: RD if they have been read, etc). If they do – they're "deleted" messages; you can usually undelete them from your IMAP client (Thunderbird and Mutt both have that function) – or you can remove the D flag manually, though this requires also removing the "dovecot.index*" files.

How can I make the Dovecot forget all the data it has stored about this mbox file and reload it whole unsorted into the inbox folder, as if it was a new installation of the server?

The mbox file is the inbox folder. Assuming the mbox itself already has the data you want (i.e. no 'D'eleted flag on the messages), you can remove the dovecot.index file (and the various other dovecot.* files that have accumulated next to it), then restart the IMAP service.

3
  • I think you must be correct. I opened that file and all the messages were marked as deleted. I guess it wasn't dovecot hiding them but my email client moving them to the virtual trash folder. It also does appear that what I thought was my missing emails, were in fact just quotes from responses I deleted - the emails I was looking for are permanently deleted. Thankfully there wasn't anything important in there that I cannot recover in some way. Commented Apr 9 at 16:39
  • Honestly it sounds like you're looking in the wrong mbox file for them? You seemed to be expecting all mail for all folders to be stored in the single mbox... Commented Apr 9 at 16:47
  • no, it appears that I accidentally deleted that mbox when trying to convert to maildir++. I guess I thought it was an empty directory when in fact it was a file. And I was mistaken about INBOX holding all of the mail, because the deleted mail made it look that way. Commented Apr 9 at 17:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .