How to Install Maddy Mail Server on Debian Latest

Maddy is a mail server written in Go that aims to be simple, fast, and easy to use while providing advanced features such as SpamAssassin integration, SMTP authentication, and more.

This tutorial will guide you through the process of setting up Maddy on Debian Latest.

Prerequisites

Before we get started, you should have:

Step 1: Install Go

Maddy is written in Go, so we need to install the Go programming language first.

  1. Update your system's package list:

    $ sudo apt update
    
  2. Install the golang package:

    $ sudo apt install golang
    

Step 2: Download and Install Maddy

  1. Clone the Maddy repository from GitHub:

    $ git clone https://github.com/foxcpp/maddy.git
    
  2. Change into the maddy directory:

    $ cd maddy
    
  3. Build the Maddy binary:

    $ go build
    
  4. Move the maddy binary to /usr/local/bin:

    $ sudo mv maddy /usr/local/bin/
    

Step 3: Configure Maddy

  1. Create a new configuration file for Maddy:

    $ sudo nano /etc/maddy/maddy.conf
    
  2. Copy and paste the following configuration into the file:

    log_file = "/var/log/maddy.log"
    
    [submission]
    bind = ":587"
    auth = "on"
    starttls_only = "yes"
    
    [mx]
    bind = ":25"
    relaying = "permit_any"
    

    This configuration configures Maddy to listen on port 587 for submission (SMTP with authentication) and port 25 for incoming messages (MX).

  3. Save and close the file.

  4. Create a log directory for Maddy:

    $ sudo mkdir /var/log/maddy
    
  5. Set permissions on the log directory:

    $ sudo chmod 755 /var/log/maddy
    
  6. Create a user and group for Maddy:

    $ sudo useradd -r maddy -s /bin/false
    
  7. Set permissions on the Maddy binary:

    $ sudo chown root:maddy /usr/local/bin/maddy
    $ sudo chmod 750 /usr/local/bin/maddy
    

Step 4: Configure DNS records

  1. Add an A record for your domain name that points to your server's IP address.

  2. Add an MX record for your domain name that points to your server's A record.

Step 5: Start and Enable Maddy

  1. Start the Maddy service:

    $ sudo systemctl start maddy
    
  2. Enable the Maddy service to start on boot:

    $ sudo systemctl enable maddy
    

Step 6: Test the Mail Server

  1. Send a test email to your server:

    $ echo "This is a test message." | mail -s "Test Message" yourname@yourdomain.com
    
  2. Check the Maddy logs for any errors:

    $ sudo tail -f /var/log/maddy.log
    

    If everything is working correctly, you should see a message similar to:

    2021/12/01 12:22:11 [smtp,maddy.domain.com:587] 220 maddy.domain.com maddy ESMTP (Maddy)
    

Congratulations! You have successfully installed Maddy and configured it to send and receive emails on your domain.

If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!

Alternatively, for the best virtual desktop, try Shells!