How to keep mail messages on servers for Apple mail?
You can begin with Setting the Download Attachments to None in you Mac Mail.

That is the biggest part of mails anyway, the rest is just text.

If you are up to the task you can then export all attachments out of your Local storage.

They are located in ~/Library/Containers/com.apple.mail/Data/Library/Mail Downloads/

You can also Export all of the mail box, to for example iCloud.
It just makes a copy of it, so you can now delete mails on your Mac, and get them again later.

To do so right click on the mailbox and use Export.

Did you know that for $1/Month you can upgrade your iCloud to 50GB.



Now if you want to automate that, like keep emails for a month then Export, you will need a Automator process for that.