Serverspace Black Friday
RF
August 13, 2022
Updated July 13, 2023

How to make fast setup for mail server on Debian 11? Part 1

Debian Linux Mail server

Introduction

This guide will help you configure your mail server with Postfix, Dovecot, MySQL and SpamAssassin in Debian 11. This setup will allow you to add virtual domains, users and aliases and protect the virtual server from spam.

Using a corporate mail for business or personal purposes offers several benefits:

  1. Professionalism: A corporate email address, such as yourname@yourcompany.com, creates a more professional image compared to generic free email providers.
  2. Branding: A corporate email allows you to promote your brand and create a consistent identity across all communication channels.
  3. Credibility: Having a dedicated email address linked to your business domain enhances credibility and trustworthiness among clients, partners, and customers.
  4. Security: Corporate email services often provide advanced security measures, such as encryption and spam filters, to protect sensitive information and prevent unauthorized access.
  5. Control and Ownership: With a corporate email, you have full control over your email infrastructure and data, ensuring privacy and compliance with data protection regulations.
  6. Collaboration: Corporate email platforms often integrate with other productivity tools like calendars, task management, and document sharing, enabling seamless collaboration within teams.
  7. Scalability: As your business grows, a corporate email service can easily accommodate the increasing number of users and provide additional features and storage capacity.
  8. Customization: You can customize the email settings, user permissions, and email policies according to your business requirements.
  9. Support: Many corporate email providers offer dedicated technical support to resolve any issues or provide assistance when needed.
  10. Separation of Personal and Business Communication: Using a separate corporate email helps separate personal and businessrelated communication, making it easier to manage and prioritize tasks.

Overall, utilizing a corporate email service offers numerous advantages in terms of professionalism, security, control, collaboration, and branding, making it a valuable asset for businesses and individuals alike.

Requirements

  • Domain name;
  • Docker CLI >= version 20
  • Docker Compose >= version 2.0;
  • Root rights;
  • Configured FQDN;
  • Optional: SSL certificate.

Install Packages:

Firts of all we need to start update packages on our system:

apt update && apt dist-upgrade
Update OS
Screenshot №1 — Update OS

Install all needed requirements and dependencies for system configuration by command:

sudo apt install apt-transport-https ca-certificates curl gnupg-agent software-properties-common -y
dependencies
Screenshot №2 — Dependencies

Add and download keys from official Docker repositories, but if you use another version of system Debian, then change link bellow:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
Curl
Screenshot №3 — Curl

This command will use utility, which set encryption key on the system and allow you to use repositories.

Now add link and update package list:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu focal stable" && apt update
Add repositories
Screenshot №4 — Add repositories

In that case we download Docker Compose as a plugin for our server, which works as standalone application by command below:

sudo apt install docker-ce docker-ce-cli containerd.io docker-compose

The plugin will containerize application and help us start 3 main modules of mail server together:

  • Mail Transfer Agent;
  • Mail User Agent;
  • Mail Delivery Agent.

Each of them complete their part of needed work in that process. We will install modern and security provided mail server, therefore, we need to use such modern protocol for transfer data. SSL will help with this requirements and one of the advantages in front of usual mail server from IT corporation it's securities!

We don't provide any data to corporation or anything else. That situation say more about our privacy, but take in mind this solution will work only with two clients on our email!

Continue our installation. Write command for add user in docker group:

sudo usermod -aG docker yourname
Usermod
Screenshot №5 — Usermod

Add domain records

For our purposes in next step we indicate and write the DNS record to our panel, in that case i use delegated panel from Serverspace and write needed records, in your case you can use anything provider:

DNS records
Screenshot №6 — DNS records

A record help our mail service to detect accordance between our domain name and IP addresses via DNS server in our example they indicate like NS record ns.02 and ns.01 with dot at the end. That need to search information about our IP address in unified format. Our domain second level vdushu.space and for mail server test.vdushu.space was wrote.

CNAME record represent synonym. In the language words of the same part of speech with full or partial coincidence of meaning. In the technologies that use for the same purposes. Any request to autoconfig.* or autodiscover.* redirect to main domain test.vdushu.space they need for docker container configuration.

MX record provide user domain name of requested canonical name. That help to determine mail server where the information will be delivered. For example we received email from sender: ussc.us and want to reply fo this message, agent make response request and recieved message like MX:test.vdushu.space, check of accordance for security issue and then send mail to mx server.

NS server or name server is main component for indicate which dns server provide maintenance for dedicated domain name. After you setup all DNS records change hostname on your Linux machine, that help in use DNS resolver /etc/resolv.conf you can check that:

hostnamectl set-hostname yourdomain.com && nano /etc/resolv.conf
Server name change
Screenshot №7 — Server name change
DNS resolver
Screenshot №8 — DNS resolver

If domain don't change then check /etc/hostname:

nano /etc/hostname

And write canonical name of domain that you use! In our example vdushu.space.

Install and config part of server

Create a worker folder for download packets via command below:

mkdir -p /main/mail && cd /main/mail
Folder
Screenshot №9 — Folder

Installation of mail server begin at the github downloading for this enter command:

apt install git && git clone https://github.com/mailcow/mailcow-dockerized
Git clone
Screenshot №10 — Git clone

Then generate config for installation via command below:

cd /main/mail/mailcow-dockerized && ./generate_config.sh
Generate config
Screenshot №11 — Generate config

Follow the instruction in popup question and requirements. You need to fill field with label Timezone, domainname, indicate with letter Y if you want to install antivirus or N to disable them, choose stable version for that installation and wait for generate SSL certificate:

Config
Screenshot №12 — Config

Conclusion

The guide aims to provide a comprehensive setup for a modern and secure mail server, utilizing Docker containers and incorporating various components for effective mail handling and delivery. In the next part of instruction we continue considering installation and configuring the server. Don't tune!

Vote:
4 out of 5
Аverage rating : 4.2
Rated by: 12
1101 CT Amsterdam The Netherlands, Herikerbergweg 292
+31 20 262-58-98
700 300
ITGLOBAL.COM NL
700 300

You might also like...

We use cookies to make your experience on the Serverspace better. By continuing to browse our website, you agree to our
Use of Cookies and Privacy Policy.