depends on the mail server, used to use qmail and its additional stuff, but its damn ugly to set up, lots of patches to apply since its 10+ years old. very good and secure server tho, also lightweight. used by yahoo and paypal.
these days id go for the packaged ones that come with the distros, since they are well tested and easy to set up.
the debian/ubuntu server kind of distros that use the debian installer, offer a choice at some point of installation:
which pretty much does the job.
then theres the account management, it comes down to 2 setups: you either use the local user accounts for mail, or you set up virtual hosts (something like virtual hosts in apache). no need to say, you need a legit domain for all this.
theoretically you must also have another mail server in case the first one fails, thats the mail servers you configure in the mx record for the domain, along with their priority.
the server must be well secured/configured/restricted too, otherwise you end up in the black lists and the other mail servers that relay/receive the mail will reject your mails. thats pretty ugly when it happens btw.
also, be prepared for all kinds of attacks and hacking attempts, and huge amounts of spam. good thing is spam filters got better over the years, so after initial setup they require attention from time to time only.
so you see its a bit ugly stuff, even more when you can use google mail for domain mail hosting etc.