تحميل

Configuring Mailcow for Email Server Management

Updated at
20/12/2023
Views
2065

Introduction: In this tutorial, you will learn how to set up your own mail server using Mailcow on an Ubuntu Server. Mailcow allows you to host your custom mail server with features like domain customization, contact synchronization, and calendar integration.

Prerequisites:

  • A domain name
  • Basic knowledge of Docker
  • Note: Some cloud servers may have port 25 and 465 blocked by default for anti-spam measures.

Step 1 - Create a New Cloud Server

  1. Sign in to your Cloud Console.
  2. Create a new project and name it accordingly.
  3. Choose a server location and type based on your needs (at least 7GB RAM for Mailcow).
  4. Click "Add Server" and select your server image. While this tutorial is based on Ubuntu 22.04, you can adapt it for Debian 11.
  5. Under "Cloud config," enter: #include https://get.docker.com (to install Docker).
  6. Select your SSH key. You can generate an SSH key if you don't have one.
  7. Enter your server hostname (e.g., mail.example.com).
  8. Click "Create & Buy Now."

Step 2 - Set Up DNS

  1. Create DNS records for your domain:
    • Create an A record for "mail.example.com" with your server's IPv4 address.
    • Create an AAAA record for "mail.example.com" with your server's IPv6 address.
    • Set up MX record pointing to "mail.example.com."
    • Create "autodiscover.example.com" and "autoconfig.example.com" CNAME records pointing to "mail.example.com."

Your DNS configuration should resemble the following:

# Name Type Value mail IN A <IPv4_address> mail IN AAAA <IPv6_address> autodiscover IN CNAME mail autoconfig IN CNAME mail @ IN MX 10 mail

Refer to Mailcow documentation for advanced DNS configurations.

Step 3 - Install Updates and Docker Compose

  1. Wait for your server to start and connect to it via SSH using your private key.
  2. Install available updates and upgrades:
apt update && apt upgrade -y
  1. Consider rebooting the server if kernel updates were installed.

Step 4 - Clone the Mailcow Repository

  1. Change your working directory to /opt:
cd /opt
  1. Clone the Mailcow GitHub repository:
git clone https://github.com/mailcow/mailcow-dockerized

Step 5 - Create Configuration, Pull Docker Containers, and Start Mailcow

  1. Change your working directory to /opt/mailcow-dockerized:
cd /opt/mailcow-dockerized
  1. Generate the Mailcow configuration:
./generate_config.sh
  1. When prompted, enter your domain name (e.g., mail.example.com).

  2. Pull Docker images:

docker-compose pull
  1. Start Mailcow:
docker-compose up -d

Step 6 - Set Up Reverse DNS Entries

  1. Access your cloud server console.
  2. Set up reverse DNS entries for your server's IPv4 and IPv6 addresses.

Step 7 - First Login to Mailcow

  1. Access your Mailcow instance at https://mail.example.org.
  2. Log in with the default credentials:
    • Username: admin
    • Password: moohoo

Important: Change your password immediately for security.

Step 8 - Add Domain(s) to Mailcow

  1. Go to "Configuration" -> "Mail setup."
  2. Under the "Domain" tab, add your domain.

Step 9 - Set Up DKIM

  1. In "Configuration" -> "Configuration & Details," select "DKIM" in the sidebar.
  2. Scroll down to the mask where you can enter your domain.
  3. Click "Select domains with missing keys" to fill in your domain name.
  4. Select a 2048 key and click "Add."
  5. Copy the public key and create a DNS TXT entry called "dkim._domainkey" with the copied content.

Step 10 - Create a Mailbox

  1. In "Configuration" -> "Mail setup," create a mailbox.
  2. Access SOGo at https://mail.example.com/SOGo.

Step 11 - Create Backups

  1. Create manual backups:

    • Connect to your server using SSH.
    • Go to the Mailcow directory with the backup script: /opt/mailcow-dockerized/helper-scripts.
    • Run the backup script: ./backup_and_restore.sh backup all --delete-days 7. Adjust the delete days as needed.
  2. Create automated backups:

    • Run crontab -e to enter your cron task list.
    • Paste the following and update details as needed:
      javascript
      0 5 * * * MAILCOW_BACKUP_LOCATION=/opt/mailcow-backups /opt/mailcow-dockerized/helper-scripts/backup_and_restore.sh backup all --delete-days 7

Step 12 - Updating Your Mailcow Instance

  1. Check for current backups before updates.
  2. Connect to your server via SSH.
  3. Go to the Mailcow directory: /opt/mailcow-dockerized.
  4. Run: ./update.sh.
  5. Confirm the update and follow on-screen instructions.
  6. After the update, do not shut down the server or Docker containers to prevent data corruption.

General Recommendations:

  • Consider storing backups in a location separate from your server (e.g., cloud storage).
  • Keep an eye on Mailcow releases for updates and security patches.

YottaSrc footer

لماذا تختارنا؟

أفضل الأسعار, تخزين SSD سريع و دعم فني
24/7 حقيقي

control panel icon
cPanel

إدارة موقعك من خلال CPanel بأحدث إصدار

security icon
سريع وموثوق وآمن

ضمان وقت تشغيل بنسبة 99.8٪.
لذا ركز على عملك!

support icon
دعم 24/7/365

ليلاً أو نهارًا ، مطر أو شمس ،
فريقنا هنا من أجلك!

cloud backup icon
نسخ احتياطي يومي

نسخ احتياطي يومي وأسبوعي.
ملفاتك آمنة!