Open Source Mail Server Maddy Deployment Tutorial


Before I introduced a complete email service RainLoop, this time we introduce another open source mail server Maddy. Maddy is written entirely in Go language, which is lightweight and easy to use.

Next, I will introduce to you how to use Maddy to build a personal email server.

In general, refer to Maddy’s official website and it can basically be built. If not, you can refer to my tutorial


  1. Apply for an SSL certificate

    Apply for certificate from

    Download and get certificate.crt and private.key

  2. Deploy the SSL certificate

    First rename the downloaded certificates to fullchain.pem and privkey.pem, and transfer them to the /software/email/maddy/certs/ directory of your own server

  3. Modify the Maddy configuration file

    Take the maddy.conf file from github, transfer it to the /software/email/maddy directory and modify the content of the configuration file, replace with your own domain name

    $(hostname) =
    $(primary_domain) =
  4. Server configuration

    docker start maddy

    docker run \
      --name maddy \
      -e \
      -e \
      -v /software/email/maddy/certs:/etc/maddy/certs/ \
      -v /software/email/maddy:/data \
      -p 25:25 \
      -p 143:143 \
      -p 587:587 \
      -p 993:993 \
      -d foxcpp/maddy:latest

    If the server pulls the docker image too slowly, you can pull it locally and then package and upload it to the server. I won’t go into details here. The key commands are the following two.

    docker save --output busybox.tar busybox
    docker load --input busybox.tar
  5. DNS configuration

    Go to the background management interface of the server manufacturer to configure DNS

    ; Basic domain->IP records, you probably already have them. 2001:beef::1
    ; It says that "server is handling messages for". 10
    ; Of course, mx1 should have A/AAAA entry as well: 2001:beef::1
    ; Use SPF to say that the servers in "MX" above are allowed to send email
    ; for this domain, and nobody else. "v=spf1 mx ~all"
    ; It is recommended to server SPF record for both domain and MX hostname "v=spf1 mx ~all"
    ; Opt-in into DMARC with permissive policy and request reports about broken
    ; messages. "v=DMARC1; p=quarantine;"
    ; Mark domain as MTA-STS compatible (see the next section)
    ; and request reports about failures to be sent to "v=STSv1; id=1" "v=TLSRPTv1;" "v=DKIM1; k=ed25519; p=nAcUUozPlhc4VPhp7hZl+owES7j7OlEv0laaDEDBAqg="
  6. Create a new user

    docker exec -it maddy sh
    maddyctl creds create # Password will prompt you to enter yourdomain
    maddyctl imap-acct create #


The above is the simple tutorial I summarized about using Maddy to build a personal mail server. Welcome to support this Go open source project.