For some reason that remains a mystery to me, Mail sometimes "thinks" it must discard the current
~/Library/Preferences/com.apple.mail.plist preferences file and create a new one. As a side effect, all your non-Mac account settings (but not the messages themselves), which are stored in that file, are lost.
What's the capacity and space available on your startup disk? Take a look at the comments about disk space in the following article, in case they apply to you:
Problems from insufficient RAM and free hard disk space
Verify/repair your disk first (not just permissions), as described here:
The Repair functions of Disk Utility: what's it all about?
Now, quit Mail if it's running and make a backup copy of the
~/Library/Mail folder, e.g. by dragging it to the Desktop while holding the Option (Alt) key down, just in case something else goes wrong while trying to solve the problem. This is where all your mail is stored.
After having fixed
all filesystem issues, if any, and backed up your mail, you have three options:
1. Restore
com.apple.mail.plist from a backup if you have one. Mail shouldn't be running while you do this.
2. Set up your non-Mac accounts in Mail again. If given the option to import existing mailboxes or something like that,
don't. Just enter the account information and Mail will automagically rediscover the data in
~/Library/Mail/ when done. You'll also have to re-configure most of your settings in
Mail > Preferences. For spam-related security reasons, the first thing you should do is go to
Preferences > Viewing and disable
Display remote images in HTML messages if it's enabled.
3. Mail may have renamed the old preferences file to
com.apple.mail.plist.saved. If that's the case, you may try moving the new
com.apple.mail.plist out of
~/Library/Preferences/ (e.g. to the Desktop) and rename the old
com.apple.mail.plist.saved back to
com.apple.mail.plist. Again, be sure Mail isn't running while doing this. Since Mail decided to discard it, I would expect this file to be corrupt (I don't understand why would Mail discard it and create a new one otherwise), but apparently that often is not the case and the settings can indeed be restored by just renaming the file.
Note: For those not familiarized with the ~/ notation, it refers to the user's home folder, i.e. ~/Library is the Library folder within the user's home folder.