Setting up Mail Server On EC2
Aaron Lin
May 10, 2021
2 min read
Tutorial
#Recently looked into setting up my own mail server and the documentation was horrible for my use case.
I started looking around the web and found some information about hMailServer & Postfix Mail Server through 5 year old videos. This brought me to learn about AWS Marketplace which allows products to be readily deployed prebuilt onto EC2 instances. Ultimately, these were not that great due to bad documentation.
There was also Postal and CyberPanel but I ultimately went with Mailcow because of the videoes available for setting it up
Alright, so what do we need?
- Route 53 domain name
- EC2 instance
1 Start with Route 53 on AWS by searching for a domain name. I personally just chose the cheapest option from the dropdown selection which came to be $5
2 Enter your contact information
3 Verify and accept if you want to renew domain automatically, accept terms & conditions, and complete order
4 It'll take a few minutes for domain registration to take place. Once you see domain registration succesful under Route 53 Dashboard, you can continue
5 In the meantime, go to EC2 and launch an Ubuntu instance. Personally I went with 20.04 and t2.small
6 Under Security Groups, you'll want to create a new security group for Mailcow. Follow this screenshot for inbound rules
Click this link to double check which ports need to be enabled
7 Attach this security group to your EC2 instance by right clicking your instance, choosing Security and Change security group Search for your security group you made, add, and save
8 Go to Elastic IPs and allocate an elastic IP address Under actions, click Associate Elastic IP Address and point it to your EC2 instance you launched
9 Under hosted zones, click your domain name and click View details. You'll want your domain to have these records. Follow this guide to double check
The A record should be pointed to your elastic IP address as value
10 The rest is super simple. SSH into the EC2 instance and follow this guide
11 If you set everything up, you should be able to access your mailcow server using: https://${MAILCOW_HOSTNAME}
with the default credentials admin + password moohoo.