I’m genuinely interested. Where would you recommend a newcomer starts?
For a pre-packaged mailserver environment, take a look at mailcow or mailinabox
There's a variety of ansible/chef/puppet up on github that can also be used to setup the invididual component
That's not really saying much.