Introduction
In this tutorial you will setup your own Mailserver running on an Ubuntu Server in the HHS VM Client Panel.
With Mailcow you can host your own Mailserver with your custom domain. Mailcow also provides a way to sync your Contacts and Calender.
Official documentation: https://mailcow.github.io/mailcow-dockerized-docs/
Project Website: https://mailcow.email
GitHub: https://github.com/mailcow/mailcow-dockerized
Forum: https://mailcow.farm
Prerequisites
- You need a domain name
- A bit of knowledge of how Docker works
Step 1 - Create a new HHS Cloud server
- Login to your cloud dashboard from [https://vps.hyperhost.solutions:4083/#act=listvs&)
- Create new project and name it whatever you want
- Choose your server location it's up to you
- Click
Add Server
and selectUbuntu 18.04
from Image - Choose the resources you need from Type
- Click on the field
User Data
enter this#include https://get.docker.com
(this will install docker) -
Select your SSH-Key
- You can read this article to know how to generate SSH key
- Write your server hostname in
name
input (mail.example.com) - Click
Create & Buy Now
Step 2 - Setup DNS
Basically you want to create a new DNS record called mail.example.com and add your server IPv4 (A record) and IPv6 (AAAA record) to it.
Then you can setup your domains MX record to point to your mail.example.com subdomain that you just created.
You also need to setup an autodiscover.example.com and autoconfig.example.com subdomain, both should be of the type CNAME and point to mail.example.com
Your DNS configuration should look like this:
# Name Type Value
mail IN A 10.0.0.1
mail IN AAAA 2001:db8:1234::1
autodiscover IN CNAME mail
autoconfig IN CNAME mail
@ IN MX 10 mail
Step 3 - Install updates on the server (Optional)
Wait a few seconds for the server to startup and then connect to it using SSH and your private key. Now you should install available updates on your server by running:
apt update && apt upgrade -y
Step 4 - Install Docker Compose
Now you need to install Docker compose you can do this by running:
curl -L https://github.com/docker/compose/releases/download/$(curl -s "https://api.github.com/repos/docker/compose/releases/latest" | awk -F '"' '/tag_name/{print $4}')/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
Step 5 - Clone the Mailcow Repository
Now we are going to clone the Mailcow GitHub repository, so first you need to cd
to /opt
with:
cd /opt
once your are in /opt you can run:git clone https://github.com/mailcow/mailcow-dockerized
Step 6 - Creating the config
Change directory to /opt/mailcow-dockerized
with cd /opt/mailcow-dockerized
and run ./generate_config.sh
this will generate the config. Now you have to enter your domain name (something like mail.example.com)
Step 7 - Pull the Docker containers
We are nearly done. Now you have to run docker-compose pull
to pull the docker images.
Step 8 - Start Mailcow
In order to start Mailcow run docker-compose up -d
Step 9 - Setup a reverse DNS entry
Go to the Client Are VM Manangement console and click on your, select the server you just created and go to the Reverse DNS Tab, select Edit Reverse DNS
, then enter your domain (mail.example.com). The same needs to be done for your IPv6 address, simply type ::1
into the field where the IP is and then again enter your domain name (mail.example.com).
Step 10 - Login and change your password
Now you can open mail.example.com in your browser and login using the default login
username: admin
password: moohoo
Please change your password :)
Step 11 - Add your domain to Mailcow
Now you can add your domain to Mailcow, simply go to Configuration
-> Mail setup
. Add your domain under the tap Domain.
Step 12 - Setup DKIM
Now when you go back to Configuration
-> Configuration & Details
you can setup DKIM. In the Configuration
tap select DKIM in the sidebar. It should be at the top, scroll down till you see the mask where you can enter your domain. Simply click Select domains with missing keys
shortcut to have your domain name filled in. Now select a 2048
key and click on Add
. Once the key is added you can copy the public key and create a DNS TXT entry called dkim._domainkey
with the content you just copied.
Step 13 - Create a mailbox
When you go back to Configuration
-> Mail setup
you can create a mailbox and log into SOGo by accessing it under https://mail.example.com/SOGo
Step 14 - Update Mailcow
Of course a mail server needs care and you should update it from time to time. Updating Mailcow is super easy simply run ./update.sh
and follow the instructions :)