First, set up the following DNS records in your domain management panel:
Optional for SMTP deliverability (not required for chatmail HTTP federation between relays): SPF, DKIM TXT at default._domainkey, and DMARC. install --domain obtains TLS and generates DKIM signing keys; you publish DNS TXT records yourself. See the operator guide DNS and Mail Authentication in the project docs.
dig +short chat.example.org A and curl -sI https://chat.example.org/mxdeliv
Madmail supports four TLS modes. The table below shows the differences:
| Mode | Challenge | DNS API | Port 80 | Use Case |
|---|---|---|---|---|
| autocert | HTTP-01 | No | Required | Production server |
| acme | DNS-01 | Yes | No | Server behind firewall |
| file | โ | โ | โ | Existing certificate |
| self_signed | โ | โ | โ | Testing & development |
sudo madmail install \ --domain chat.example.org \ --tls-mode autocert \ --acme-email [email protected] \ --enable-chatmail \ --non-interactive
How it works:
/var/lib/madmail/autocert/In the configuration file (madmail.conf):
tls {
loader autocert {
hostname chat.example.org
email [email protected]
cache_dir /var/lib/madmail/autocert
agreed
}
}
sudo madmail install \ --domain chat.example.org \ --tls-mode acme \ --acme-email [email protected] \ --acme-dns-provider cloudflare \ --acme-dns-token "YOUR_CLOUDFLARE_TOKEN" \ --enable-chatmail \ --non-interactive
Supported DNS providers: cloudflare, gandi,
digitalocean, vultr, hetzner, route53
sudo madmail install \ --domain chat.example.org \ --tls-mode file \ --cert-path /etc/letsencrypt/live/chat.example.org/fullchain.pem \ --key-path /etc/letsencrypt/live/chat.example.org/privkey.pem \ --enable-chatmail
Configuration file format:
sudo madmail install \ --simple --ip YOUR_SERVER_IP \ --tls-mode self_signed \ --turn-off-tls
Certificates are stored in /var/lib/madmail/certs/ and reused on subsequent restarts.
After setup, verify your certificate with this command:
Expected output:
sudo rm /var/lib/madmail/certs/fullchain.pem /var/lib/madmail/certs/privkey.pem
sudo madmail install \ --domain chat.example.org \ --tls-mode autocert \ --acme-email [email protected] \ --enable-chatmail \ --non-interactive
sudo systemctl restart madmail
Run the following commands to fix file ownership and permissions:
sudo chown root:madmail /path/to/cert.pem /path/to/key.pem sudo chmod 640 /path/to/cert.pem /path/to/key.pem
600 permissions (owner only)640 permissions (owner + group)700 permissions (owner only)