>Setting this up is going to take a lot of research and work. Yeah, copy-pasting 3 lines into terminal, using a solution like
https://modoboa.org/en/ (there are many others, like mail-in-a-box)
There are not many ways of properly configuring a mail server and this problem is generally considered to be solved.
You'll have bigger problem exposing your raspberry pi to the internet, as your provider most likely doesn't give you a real IP address. You'll need either that, or your own VPN on a hosting, that would route incoming connections back to your home. Both would cost money, so I'd recommend getting a VPS for that, they are as cheap as 5$/month. You'll have to trust that hosting company, though.