onesystems/mailrelayThis project provides a minimal, modern, and debuggable Postfix-based SMTP relay packaged as a Docker container. It is designed to act as a reliable infrastructure component, relaying mail from internal systems to an upstream SMTP server with TLS and SASL authentication.
The image focuses on:
docker logsIn addition, it includes built-in alerting for delivery and identity failures, with optional integration into Zammad as tickets instead of sending alert emails.
docker logsyamlversion: "3.9" services: mailrelay: build: . container_name: mailrelay restart: unless-stopped ports: - "25:25" # expose only on trusted/internal networks environment: HOSTNAME_FQDN: "mailrelay.example.local" # Fixed sender handling DEFAULT_FROM: "***" FORCE_DEFAULT_FROM: "1" # Relay target RELAY_HOST: "smtp.example.local" RELAY_PORT: "587" RELAY_TLS: "required" # Allowed client networks MYNETWORKS: "127.0.0.0/8,10.0.0.0/8,192.168.0.0/16" # SASL authentication RELAY_SASL_USER: "***" RELAY_SASL_PASS_FILE: "/run/secrets/relay_sasl_pass" # Alerting ALERT_ENABLED: "1" ALERT_MATCH: "invalid_user,sendas_denied,postfix_bounced,postfix_deferred" # Zammad integration ALERT_ZAMMAD_ENABLED: "1" ZAMMAD_BASE_URL: "[***]" ZAMMAD_TOKEN_FILE: "/run/secrets/zammad_token" ZAMMAD_GROUP: "Support" ZAMMAD_STATE: "new" ZAMMAD_PRIORITY_ID: "2" # 1=low, 2=normal, 3=high ZAMMAD_CUSTOMER_*** "***" ZAMMAD_TAGS: "mailrelay,postfix,alert" # Debugging DEBUG: "1" secrets: - relay_sasl_pass - zammad_token volumes: - postfix_spool:/var/spool/postfix - postfix_state:/var/lib/postfix - /etc/ssl/certs:/etc/ssl/certs:ro secrets: relay_sasl_pass: file: ./secrets/relay_sasl_pass.txt zammad_token: file: ./secrets/zammad_token.txt volumes: postfix_spool: postfix_state:
relay_sasl_pass.txtThe secret file must contain only the password (no username):
textsuper-secret-password
The username is configured via RELAY_SASL_USER.
zammad_token.txtContains a Zammad API token with permission to create tickets:
textzammad-api-token-here
Many SMTP relays reject mails if the sender does not match the authenticated user.
This image enforces a safe default:
DEFAULT_FROM is set → local senders are rewritten to this addressRELAY_SASL_USERThis avoids errors like:
553 5.7.1 Sender address rejected: not owned by user
Sender rewriting is applied only to local / infrastructure senders (e.g. root, daemon, host-based senders).
The container continuously monitors Postfix logs and triggers alerts on actionable failures, including:
invalid_user – upstream mailbox or identity does not existsendas_denied – sender not permitted to send as this addresspostfix_bounced – delivery permanently failedpostfix_deferred – delivery temporarily failedAlert detection is regex-based and operates directly on the Postfix log stream.
Alerts are throttled to avoid flooding during repeated failures.
Each alert creates an internal Zammad ticket containing:
postfix_bounced, ErrorInvalidUser)This makes the relay suitable for production use without silent mail loss.
swaksbashdocker exec -it mailrelay swaks \ --to *** \ --from *** \ --server 127.0.0.1 \ --port 25 \ --header "Subject: Relay test" \ --data "Hello from mailrelay"
sendmailbashdocker exec -i mailrelay sendmail *** <<EOF From: *** To: *** Subject: Relay test Hello from mailrelay EOF
⚠️ Do not use sendmail -v unless you want delivery status notifications sent back to you.
All Postfix logs are written to a file and streamed to stdout:
bashdocker logs -f mailrelay
This makes it possible to audit delivery and alerting via Docker logs alone.
MYNETWORKSMichael Kleger OneSystems GmbH [***]
MIT License – free for commercial and private use.
探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
在 Linux 系统配置镜像服务
在 Docker Desktop 配置镜像
Docker Compose 项目配置
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
MacOS OrbStack 容器配置
在宝塔面板一键配置镜像
Synology 群晖 NAS 配置
飞牛 fnOS 系统配置镜像
极空间 NAS 系统配置服务
爱快 iKuai 路由系统配置
绿联 NAS 系统配置镜像
QNAP 威联通 NAS 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
无需登录使用专属域名
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
免费版仅支持 Docker Hub 访问,不承诺可用性和速度;专业版支持更多镜像源,保证可用性和稳定速度,提供优先客服响应。
专业版支持 docker.io、gcr.io、ghcr.io、registry.k8s.io、nvcr.io、quay.io、mcr.microsoft.com、docker.elastic.co 等;免费版仅支持 docker.io。
当返回 402 Payment Required 错误时,表示流量已耗尽,需要充值流量包以恢复服务。
通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。
先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。
使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。
来自真实用户的反馈,见证轩辕镜像的优质服务