My Mac panicked and crashed and when I started it up again all of my mail accounts were gone. And when Mail started it presented the initial "setup up a new account" wizard.
Looking into the Mail archive, ~/Library/Mail, the mailboxes seemed intact. There were files there and Spotlight was capable of both displaying and listing my mails. But in the "MailData" directory the Accounts.plist file had lost all accounts. After recovering Accounts.plist from a Time Machine backup, Mail started ok and all mails and accounts were intact.
To recover Accounts.plist do the following:
- Use Finder to navigate to ~/Library/Mail/V2/MailData.
- Ensure "MailData" is selected.
- Enter Time Machine and move back in time to a date/time you know Mail worked OK.
- Recover "Accounts.plist".
- Exit Time Machine.
- Start Mail.
Note; I use Mail v5.2.