Ansible Playbook to Create an IMAP Server Hosting Multiple Domains

Here is an Ansible playbook to set up a server as an IMAP server hosting email for multiple domains. Just bring your own server!
https://github.com/shuchow/postfix-dovecot-virtualhosts

Features:
1. Host email for multiple domains on one single server.
2. Emails and Domains are managed by MariaDB/MySQL.
3. Uses Ansible Vault to secure sensitive information.
4. Uses Let’s Encrypt to generate certs, providing a secure connection to the server.
5. Supports Gandi and Amazon Route 53 DNS. PRs for other DNS providers welcome.

The motivation for this came about because of the recent trend by free domain email hosting services, like Google Workplace, removing free plans. I have a few domains, with one or two emails each. I send *maybe* an email a month from each account. Incoming emails are slow and steady. It’s not financially feasible for me to keep these rarely-used email addresses around since email providers like to charge per domain. I decided to set up my own server to keep the email addresses in use.

My setup spreads my domains across two different servers, one of them hosts websites on them along with email. However, this repo keeps it simple by focusing all domains to one server.

What this setup does *not* do is host SMTP for sending mail. I tried to do this, but for a variety of reasons, but mainly it’s tricky and risky. I just decided to use Amazon SES for this. I’ll probably write another blog post in the future about that.

Leave a Reply