# Mail Server Lightweight Hardening Implementation Plan > **For Claude:** REQUIRED SUB-SKILL: Use superpowers:executing-plans to implement this plan task-by-task. **Goal:** Harden the mail server with spam filtering (Rspamd), DMARC enforcement, rate limiting, monitoring alerts, and hygiene cleanup. **Status**: Completed. ForwardEmail references in this plan are historical — relay removed 2026-04-12. MX points directly to mail.viktorbarzin.me. **Architecture:** All changes are to the existing docker-mailserver 15.0.0 deployment managed by Terraform. Rspamd replaces OpenDKIM for DKIM signing and adds spam filtering. DMARC moves from `none` to `quarantine` in Cloudflare DNS. Postfix gets rate-limiting parameters. Prometheus gets a mailserver-down alert. Roundcubemail debug logging is disabled and image pinned. **Tech Stack:** Terraform/HCL, docker-mailserver, Rspamd, Cloudflare DNS, Prometheus --- ### Task 1: Enable Rspamd and disable OpenDKIM **Files:** - Modify: `stacks/platform/modules/mailserver/main.tf:39-62` (env ConfigMap) **Step 1: Add Rspamd env vars to the ConfigMap** In `stacks/platform/modules/mailserver/main.tf`, in the `kubernetes_config_map.mailserver_env_config` resource `data` block, add these entries and modify existing ones: ```hcl data = { DMS_DEBUG = "0" ENABLE_CLAMAV = "0" ENABLE_AMAVIS = "0" ENABLE_FAIL2BAN = "0" ENABLE_FETCHMAIL = "0" ENABLE_POSTGREY = "0" ENABLE_SASLAUTHD = "0" ENABLE_SPAMASSASSIN = "0" ENABLE_SRS = "1" ENABLE_RSPAMD = "1" ENABLE_OPENDKIM = "0" ENABLE_OPENDMARC = "0" RSPAMD_LEARN = "1" FETCHMAIL_POLL = "120" ONE_DIR = "1" OVERRIDE_HOSTNAME = "mail.viktorbarzin.me" POSTFIX_MESSAGE_SIZE_LIMIT = 1024 * 1024 * 200 # 200 MB POSTFIX_REJECT_UNKNOWN_CLIENT_HOSTNAME = "1" DEFAULT_RELAY_HOST = "[smtp.eu.mailgun.org]:587" SPOOF_PROTECTION = "1" SSL_TYPE = "manual" SSL_CERT_PATH = "/tmp/ssl/tls.crt" SSL_KEY_PATH = "/tmp/ssl/tls.key" } ``` The key additions are: `ENABLE_RSPAMD = "1"`, `ENABLE_OPENDKIM = "0"`, `ENABLE_OPENDMARC = "0"`, `RSPAMD_LEARN = "1"`. **Note:** The existing OpenDKIM volume mounts (KeyTable, SigningTable, TrustedHosts, opendkim keys) should stay mounted. docker-mailserver's Rspamd integration reads the DKIM key from the same path (`/tmp/docker-mailserver/opendkim/keys/`) to configure Rspamd's DKIM signing module automatically. **Step 2: Commit** ```bash git add stacks/platform/modules/mailserver/main.tf git commit -m "[ci skip] mailserver: enable Rspamd, disable OpenDKIM" ``` --- ### Task 2: Add Postfix rate limiting **Files:** - Modify: `stacks/platform/modules/mailserver/variables.tf:3-22` (postfix_cf variable) **Step 1: Add rate limiting parameters to postfix_cf** In `stacks/platform/modules/mailserver/variables.tf`, append these lines to the `postfix_cf` default value, before the `EOT`: ``` smtpd_client_connection_rate_limit = 10 smtpd_client_message_rate_limit = 30 anvil_rate_time_unit = 60s ``` The full `postfix_cf` variable should become: ```hcl variable "postfix_cf" { default = <