Running 10.13.6. Mail runs for a while and after reading messages, sometimes all messages, it quits with the unexpected message.
Sometimes even after quitting Mail normally the message may pop up after a minute or two..
Most commonly a problem such as yours is caused by a corrupted/malicious e-mail or e-mail attachment that is causing Mail to choke. The way to deal with that is to log into your ISP's mail server using the Web-based interface most ISP's provide and to delete the problematic e-mail manually. The problematic one is usually easy to spot. It's usually either spammy or unreadable. (i.e. it's usually e-mail that you would delete anyway.) If your ISP doesn't offer a Web interface, you can:
Select the desired Inbox in the Sidebar of Mail
Do a Command + I on it or right click on it and choose Get Account Info
A popup window will appear which, in most cases, will allow you to display a list of the messages on the server.. except...
In Catalina it's a bit different:
In Mail on your Mac, check and change information for the email accounts you use in Mail.
support.apple.com
If that doesn't work, I'd quit Mail, move Mail's "Mail Downloads" folder to the desktop, relaunch mail, and see if the problem is gone. If it is, your problem is a corrupted e-mail attachment.
To get there in recent versions of the MacOS (where the user Library is invisible),
In the Finder
Option-click the Go menu
Your ~/Library will appear in the menu