To repair the mail folder, export your contacts list and your feeds list (if you have any feeds). Then, close down Opera and rename the "mail" folder. Then, start Opera and set up all your accounts fresh.

Then, for each POP account that you just set up, goto "Menu -> settings -> import and export -> import mail -> import generic mbox -> add folder" and import into the existing POP account. You'll want to point it to the store/accountN folder in the "mail" folder where N is the number for the account (look for the email address tied to the account) as seen in accounts.ini in that mail folder. In most cases, you'd import from the "mail" folder you just renamed. But, if you know that mail folder doesn't have all your messages, import from a "mail" folder that does.

Once you import the messages, for any duplicates in the POP accounts you have, delete the imported copies and keep the unread, newly-fetched copies from the server (which you can then mark as read).

Then you can import your contacts and feeds.

You also have to recreate your Opera labels if you want them back. And, for any messages that were manually added to those labels, you'll have to add them back again.

Note that for newsgroup accounts, you won't be able to restore already-fetched messages that are no longer on the server. Likewise, for feeds, you won't be able to restore already-fetched feed messages that are no longer on the feed page.

Also note that you won't be able to restore drafts as drafts. Drafts for all accounts are mixed together in the store/drafts folder. You can import them to a new account or existing account though if you want. Or, you can import each mbs file into the proper account, but that will involve examining the mbs files. Not sure you'll be able to restore the cached attachment files though.