Resolving "There is a problem with your mailboxes." in El Capitan
Solution 1:
I too am having this issue since upgrading to El Capitan in October. It is quite frustrating as any email being composed is lost once the error dialog box hits.
The only partial work around I have found is deleting the log files found at: \library\containers\com.apple.mail\Data\library\logs\Mail*.log
Mail seems to keep writing to these log files, using more and more ram in the process, until mail becomes unresponsive and the error dialog appears.