Quit Mail if it's running. This procedure will have no effect unless you quit Mail when you begin.
Back up all data.
Triple-click anywhere in the line below on this page to select it:
sqlite3 L*/C*/*.mail/*/L*/*/*/C*.db vacuum; sqlite3 L*/M*/*/*/E*ex vacuum
Copy the selected text to the Clipboard by pressing the key combination command-C.
Launch the built-in Terminal application in any of the following ways:
☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
☞ Open LaunchPad and start typing the name.
Paste into the Terminal window (command-V).
You should see a new line ending in a dollar sign ($) appear below what you entered. If not, press return. You can then quit Terminal and relaunch Mail. Test.