Mail server?

Hi everyone, I was wondering if it would be possible to run a mail server on a EX2 Ultra?
I’m a pretty basic user but my idea would be to buy a domain and run a mail server on the NAS, so I can check my mails from my phone or from the mail app in windows, no need for a website.
Would need to be IMAP so everything gets sync’d on all devices as far as I understand.
Any idea if something like that can be done?