专属域名
文档搜索
轩辕助手
Run助手
邀请有礼
返回顶部
快速返回页面顶部
收起
收起工具栏
轩辕镜像 官方专业版
轩辕镜像 官方专业版轩辕镜像 官方专业版官方专业版
首页个人中心搜索镜像

交易
充值流量我的订单
工具
提交工单镜像收录一键安装
Npm 源Pip 源Homebrew 源
帮助
常见问题
其他
关于我们网站地图

官方QQ群: 1072982923

onesystems/mailrelay Docker 镜像 - 轩辕镜像

mailrelay
onesystems/mailrelay
onesystems
Minimal Postfix-based SMTP relay with TLS/SASL and docker-friendly logging.
0 次下载
😅 镜像要是出问题,背锅的一定是你
镜像简介版本下载
😅 镜像要是出问题,背锅的一定是你

📬 Postfix SMTP Relay Docker

This 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:

  • correctness
  • clear logging via docker logs
  • predictable sender handling
  • zero open-relay risk

In addition, it includes built-in alerting for delivery and identity failures, with optional integration into Zammad as tickets instead of sending alert emails.


🚀 Features

  • Postfix-based SMTP relay (no mailbox storage)
  • TLS-secured relay to upstream SMTP (port 587)
  • SASL authentication via Docker secrets
  • Forced sender rewriting (prevents upstream rejections)
  • Clean, full mail logs available via docker logs
  • Safe defaults (no open relay)
  • Alerting on delivery failures and identity issues
  • Optional Zammad ticket creation for alerts
  • Designed for internal infrastructure use

🐳 Usage (Docker Compose)

yaml
version: "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:

🔐 Secrets

relay_sasl_pass.txt

The secret file must contain only the password (no username):

text
super-secret-password

The username is configured via RELAY_SASL_USER.

zammad_token.txt

Contains a Zammad API token with permission to create tickets:

text
zammad-api-token-here

✉️ Sender Handling (Important)

Many SMTP relays reject mails if the sender does not match the authenticated user.

This image enforces a safe default:

  • If DEFAULT_FROM is set → local senders are rewritten to this address
  • Otherwise → fallback to RELAY_SASL_USER

This 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).


🚨 Alerting & Monitoring

The container continuously monitors Postfix logs and triggers alerts on actionable failures, including:

  • invalid_user – upstream mailbox or identity does not exist
  • sendas_denied – sender not permitted to send as this address
  • postfix_bounced – delivery permanently failed
  • postfix_deferred – delivery temporarily failed

Alert detection is regex-based and operates directly on the Postfix log stream.

Alert Flow
  1. Postfix writes a failure to the log
  2. The internal watcher matches the error
  3. Context (queue ID, sender, recipient, reason) is extracted
  4. A Zammad ticket is created with full diagnostic details

Alerts are throttled to avoid flooding during repeated failures.


🎟 Zammad Ticket Details

Each alert creates an internal Zammad ticket containing:

  • Failure type (e.g. postfix_bounced, ErrorInvalidUser)
  • Affected sender and recipient (best effort)
  • Queue ID
  • Full Postfix error reason
  • Recent log context
  • Fix hints for common identity problems

This makes the relay suitable for production use without silent mail loss.


🧪 Testing the Relay

Recommended: swaks
bash
docker exec -it mailrelay swaks \
  --to *** \
  --from *** \
  --server 127.0.0.1 \
  --port 25 \
  --header "Subject: Relay test" \
  --data "Hello from mailrelay"
Using sendmail
bash
docker 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.


📜 Logs

All Postfix logs are written to a file and streamed to stdout:

bash
docker logs -f mailrelay

This makes it possible to audit delivery and alerting via Docker logs alone.


🔒 Security Notes

  • This container is not a public mail server
  • Never expose port 25 to the internet
  • Always restrict MYNETWORKS
  • No mailboxes are stored; this is a pure relay

🧑‍💻 Author

Michael Kleger OneSystems GmbH [***]



📝 License

MIT License – free for commercial and private use.

查看更多 mailrelay 相关镜像 →
onesystems/dockerbackup logo
onesystems/dockerbackup
onesystems
基于Alpine的轻量级容器,用于定时备份目录和数据库(PostgreSQL/MariaDB/MySQL),支持保留策略、清理旧备份及Nextcloud Talk Bot/邮件通知。
50K+ pulls
上次更新:3 个月前
onesystems/semaphore logo
onesystems/semaphore
onesystems
从semaphoreui/semaphore派生的Docker镜像,已预装WinRM,支持通过Ansible UI管理Windows主机的远程任务调度与自动化操作。
10K+ pulls
上次更新:15 天前
onesystems/bookstackbackup logo
onesystems/bookstackbackup
onesystems
为BookStack提供轻量级容器化备份解决方案,支持PDF导出、定时备份、旧备份清理,以及可选的Nextcloud WebDAV上传和多渠道错误通知(邮件、Nextcloud Talk)。
10K+ pulls
上次更新:7 个月前

轩辕镜像配置手册

探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式

登录仓库拉取

通过 Docker 登录认证访问私有仓库

Linux

在 Linux 系统配置镜像服务

Windows/Mac

在 Docker Desktop 配置镜像

Docker Compose

Docker Compose 项目配置

K8s Containerd

Kubernetes 集群配置 Containerd

K3s

K3s 轻量级 Kubernetes 镜像加速

Dev Containers

VS Code Dev Containers 配置

MacOS OrbStack

MacOS OrbStack 容器配置

宝塔面板

在宝塔面板一键配置镜像

群晖

Synology 群晖 NAS 配置

飞牛

飞牛 fnOS 系统配置镜像

极空间

极空间 NAS 系统配置服务

爱快路由

爱快 iKuai 路由系统配置

绿联

绿联 NAS 系统配置镜像

威联通

QNAP 威联通 NAS 配置

Podman

Podman 容器引擎配置

Singularity/Apptainer

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 错误时,表示流量已耗尽,需要充值流量包以恢复服务。

410 错误问题

通常由 Docker 版本过低导致,需要升级到 20.x 或更高版本以支持 V2 协议。

manifest unknown 错误

先检查 Docker 版本,版本过低则升级;版本正常则验证镜像信息是否正确。

镜像拉取成功后,如何去掉轩辕镜像域名前缀?

使用 docker tag 命令为镜像打上新标签,去掉域名前缀,使镜像名称更简洁。

查看全部问题→

用户好评

来自真实用户的反馈,见证轩辕镜像的优质服务

用户头像

oldzhang

运维工程师

Linux服务器

5

"Docker访问体验非常流畅,大镜像也能快速完成下载。"

轩辕镜像
镜像详情
...
onesystems/mailrelay
官方博客Docker 镜像使用技巧与技术博客
热门镜像查看热门 Docker 镜像推荐
一键安装一键安装 Docker 并配置镜像源
咨询镜像拉取问题请 提交工单,官方技术交流群:1072982923
轩辕镜像面向开发者与科研用户,提供开源镜像的搜索和访问支持。所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
咨询镜像拉取问题请提交工单,官方技术交流群:
轩辕镜像面向开发者与科研用户,提供开源镜像的搜索和访问支持。所有镜像均来源于原始仓库,本站不存储、不修改、不传播任何镜像内容。
官方邮箱:点击复制邮箱
©2024-2026 源码跳动
官方邮箱:点击复制邮箱Copyright © 2024-2026 杭州源码跳动科技有限公司. All rights reserved.