Mailgun is a service you sign up for (which makes it super easy ). If you’re looking to try and set up your own mail server, there’s this topic with a range of advice in which might be useful - Where can I find steps for setting up email with my own SMTP server?
But for out-going mail it’s recommended to use a proper service for a hassle-free life.