Yesterday, I wanted to delete some of the old email accounts I had set up in Apple Mail, but I didn’t want to lose access to their emails because they have information I might want to reference later. There are many reasons you’d want to do this — for example, you have a school-provided account where you lose access upon graduation.
There are two kinds of mailboxes in Apple Mail — ones that sync with an associated email server, and “On My Mac” mailboxes that only exist on your Mac. Basically, copy all messages into an “On My Mac” mailbox before you delete the account.
First, make a new local mailbox to store the messages after your account is deleted. Go to Mailbox > New Mailbox and this sheet will show up:
Now go to the mailbox you want to archive and select all the messages. Right click your selection and go to Copy To > (The name of your newly created mailbox).
(Instead of copying the messages, you could also move the associated files, since mailboxes are stored as folders under ~/Library/Mail/. But that’ll probably break things subtly — maybe Spotlight indexing or something.)
Once you’ve made a local copy of every mailbox, you’re now free to delete the account without losing messages.