Install archivemail by entering the following commands in the terminal:
sudo apt update sudo apt install archivemail
archive and compress or delete your old email
Archivemail moves old mail out of a mailbox (in Maildir, MH, or mbox format, or via IMAP) and archives it in a compressed mbox-format mailbox file. It is well suited to be run from cron for automatic archiving of your old mail. Archivemail can also just delete old mail so it is useful for cleaning up mailing list or spam mailboxes.