docker-postfix

docker-postfix

Docker化的Postfix邮件中继服务器

docker-postfix是基于Debian的Postfix邮件中继Docker镜像,用于在Docker环境中集中管理外发电子邮件。支持直接发送和通过中继服务器转发,针对应用程序邮件队列优化,提供灵活配置、DKIM签名,跨平台兼容多种架构。适合需要可靠SMTP发送功能的应用和服务使用。

DockerPostfix邮件服务器SMTP容器化Github开源项目

docker-postfix

Build status Latest commit Latest release Docker image size GitHub Repo stars Docker Stars Docker Pulls License FOSSA Status

Simple postfix relay host ("postfix null client") for your Docker containers. Based on Debian (default), Ubuntu and Alpine Linux. Feel free to pick your favourite distro.

Table of contents

Description

This image allows you to run POSTFIX internally inside your docker cloud/swarm installation to centralise outgoing email sending. The embedded postfix enables you to either send messages directly or relay them to your company's main server.

This is a server side POSTFIX image, geared towards emails that need to be sent from your applications. That's why this postfix configuration does not support username / password login or similar client-side security features.

IF YOU WANT TO SET UP AND MANAGE A POSTFIX INSTALLATION FOR END USERS, THIS IMAGE IS NOT FOR YOU. If you need it to manage your application's outgoing queue, read on.

TL;DR

To run the container, do the following:

docker run --rm --name postfix -e "ALLOWED_SENDER_DOMAINS=example.com" -p 1587:587 boky/postfix

or

helm repo add bokysan https://bokysan.github.io/docker-postfix/ helm upgrade --install --set persistence.enabled=false --set config.general.ALLOW_EMPTY_SENDER_DOMAINS=yes mail bokysan/mail

You can also find this image at ArtifactHub.

You can now send emails by using localhost:1587 (on Docker) as your SMTP server address. Note that if you haven't configured your domain to allow sending from this IP/server/nameblock, your emails will most likely be regarded as spam.

All standard caveats of configuring the SMTP server apply:

  • MAKE SURE YOUR OUTGOING PORT 25 IS NOT BLOCKED.
    • Most ISPs block outgoing connections to port 25 and several companies (e.g. NoIP, Dynu) offer workarounds.
    • Hosting centers also tend to block port 25, which can be unblocked per request, see below for AWS hosting.
  • You'll most likely need to at least set up SPF records (see also openspf) and/or DKIM.
  • If using DKIM (below), make sure to add DKIM keys to your domain's DNS entries.
  • You'll most likely need to set up PTR records as well to prevent your mails going to spam.

If you don't know what any of the above means, get some help. Google is your friend. It's also worth noting that it's pretty difficult to host a SMTP server on a dynamic IP address.

Please note that the image uses the submission (587) port by default. Port 25 is not exposed on purpose, as it's regularly blocked by ISPs, already occupied by other services, and in general should only be used for server-to-server communication.

Updates

v4.0.0

Several potentially "surprising" changes went into this issue and hence warrant a version upgrade:

  • Default image is now based on Debian. A lot of packages needed for latest builds are missing in certain Alpine architectures. Debian allows us to have a greater cross-platform availability.
  • Helm charts are now built with v and without v prefix. As seen in PR #141 some tools rely on version not having the prefix. I've seen both in the wild, so the image now includes both. This should work and should hopefully provide most compatibility.
  • master branch now builds images called edge. latest images are built from the last tag. We've had several issues with people using the latest tag and reporting problems. You can now rely on latest being the latest stable release.
  • Image now builds its own version of postfix-exporter and relies on this third-party project. Checkout is from master branch, based on specific SHA commit id. The same hash is used for master and tags.
  • Architecture galore! With the addition of debian images, we now support support more architectures than ever. The list includes: linux/386, linux/amd64, linux/arm/v5, linux/arm/v6, linux/arm/v7, linux/arm64, linux/arm64/v8, linux/mips64le, linux/ppc64le and linux/s390x.
  • smtpd_tls_security_level is now set to may. If you encounter issues, try setting it to none explicitly (see #160).

v3.0.0

There's a potentially breaking change introduced now in v3.0.0: Oracle has changed the license of BerkleyDB to AGPL-3.0, making it unsuitable to link to packages with GPL-incompatible licenses. As a result Alpine (on which this image is based) has deprecated BerkleyDB throughout the image:

Support for Postfix hash and btree databases has been removed. lmdb is the recommended replacement. Before upgrading, all tables in /etc/postfix/main.cf using hash and btree must be changed to a supported alternative. See the Postfix lookup table documentation for more information.

While this should not affect most of the users (/etc/postfix/main.cf is managed by this image), there might be use cases where people have their own configuration which relies on hash and btree databases. To avoid braking live systems, the version of this image has been updated to v3.0.0.

Architectures

Available for all your favourite architectures. Run in your server cluster. Run it on your Raspberry Pi 4. Run it on your ancient Pentium or an old Beaglebone. The following architectures are supported: linux/386, linux/amd64, linux/arm/v6, linux/arm/v7, linux/arm64 and linux/ppc64le.

Configuration options

General options

  • TZ = The timezone for the image, e.g. Europe/Amsterdam
  • FORCE_COLOR = Set to 1 to force color output (otherwise auto-detected)
  • INBOUND_DEBUGGING = Set to 1 to enable detailed debugging in the logs
  • ALLOWED_SENDER_DOMAINS = domains which are allowed to send email via this server
  • ALLOW_EMPTY_SENDER_DOMAINS = if value is set (i.e: true), ALLOWED_SENDER_DOMAINS can be unset
  • LOG_FORMAT = Set your log format (JSON or plain)

Inbound debugging

Enable additional debugging for any connection coming from POSTFIX_mynetworks. Set to a non-empty string (usually 1 or yes) to enable debugging.

ALLOWED_SENDER_DOMAINS and ALLOW_EMPTY_SENDER_DOMAINS

Due to in-built spam protection in Postfix you will need to specify sender domains -- the domains you are using to send your emails from, otherwise Postfix will refuse to start.

Example:

docker run --rm --name postfix -e "ALLOWED_SENDER_DOMAINS=example.com example.org" -p 1587:587 boky/postfix

If you want to set the restrictions on the recipient and not on the sender (anyone can send mails but just to a single domain for instance), set ALLOW_EMPTY_SENDER_DOMAINS to a non-empty value (e.g. true) and ALLOWED_SENDER_DOMAINS to an empty string. Then extend this image through custom scripts to configure Postfix further.

Log format

The image will by default output logs in human-readable (plain) format. If you are deploying the image to Kubernetes, it might be worth changing the output format to json as it's more easily parsable by tools such as Prometheus.

To change the log format, set the (unsurprisingly named) variable LOG_FORMAT=json.

Postfix-specific options

  • RELAYHOST = Host that relays your messages
  • SASL_RELAYHOST = (optional) Relay Host referenced in the sasl_passwd file. Defaults to the value of RELAYHOST
  • RELAYHOST_USERNAME = An (optional) username for the relay server
  • RELAYHOST_PASSWORD = An (optional) login password for the relay server
  • RELAYHOST_PASSWORD_FILE = An (optional) file containing the login password for the relay server. Mutually exclusive with the previous option.
  • POSTFIX_smtp_tls_security_level = Relay host TLS connection level
  • XOAUTH2_CLIENT_ID = OAuth2 client id used when configured as a relayhost.
  • XOAUTH2_SECRET = OAuth2 secret used when configured as a relayhost.
  • XOAUTH2_INITIAL_ACCESS_TOKEN = Initial OAuth2 access token.
  • XOAUTH2_INITIAL_REFRESH_TOKEN = Initial OAuth2 refresh token.
  • XOAUTH2_TOKEN_ENDPOINT = Token endpoint provided four your XOAUTH App , GMail use : https://accounts.google.com/o/oauth2/token
  • SMTPD_SASL_USERS = Users allow to send mail (ex: user1:pass1,user2:pass2,...). Warning: Users need to be specified with a domain, as explained on ticket [#192]. This image will automatically add a domain if one is not provided and will issue a notice when that happens.
  • MASQUERADED_DOMAINS = domains where you want to masquerade internal hosts
  • SMTP_HEADER_CHECKS= Set to 1 to enable header checks of to a location of the file for header checks
  • POSTFIX_myhostname = Set the name of this postfix server
  • POSTFIX_mynetworks = Allow sending mails only from specific networks ( default 127.0.0.0/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16 )
  • POSTFIX_message_size_limit = The maximum size of the message, in bytes, by default it's unlimited
  • POSTFIX_<any_postfix_setting> = provide any additional postfix setting

RELAYHOST, RELAYHOST_USERNAME and RELAYHOST_PASSWORD

Postfix will try to deliver emails directly to the target server. If you are behind a firewall, or inside a corporation you will most likely have a dedicated outgoing mail server. By setting this option, you will instruct postfix to relay (hence the name) all incoming emails to the target server for actual delivery.

Example:

docker run --rm --name postfix -e RELAYHOST=192.168.115.215 -p 1587:587 boky/postfix

You may optionally specifiy a relay port, e.g.:

docker run --rm --name postfix -e RELAYHOST=192.168.115.215:587 -p 1587:587 boky/postfix

Or an IPv6 address, e.g.:

docker run --rm --name postfix -e

编辑推荐精选

蛙蛙写作

蛙蛙写作

AI小说写作助手,一站式润色、改写、扩写

蛙蛙写作—国内先进的AI写作平台,涵盖小说、学术、社交媒体等多场景。提供续写、改写、润色等功能,助力创作者高效优化写作流程。界面简洁,功能全面,适合各类写作者提升内容品质和工作效率。

AI辅助写作AI工具蛙蛙写作AI写作工具学术助手办公助手营销助手AI助手
Trae

Trae

字节跳动发布的AI编程神器IDE

Trae是一种自适应的集成开发环境(IDE),通过自动化和多元协作改变开发流程。利用Trae,团队能够更快速、精确地编写和部署代码,从而提高编程效率和项目交付速度。Trae具备上下文感知和代码自动完成功能,是提升开发效率的理想工具。

AI工具TraeAI IDE协作生产力转型热门
问小白

问小白

全能AI智能助手,随时解答生活与工作的多样问题

问小白,由元石科技研发的AI智能助手,快速准确地解答各种生活和工作问题,包括但不限于搜索、规划和社交互动,帮助用户在日常生活中提高效率,轻松管理个人事务。

热门AI助手AI对话AI工具聊天机器人
Transly

Transly

实时语音翻译/同声传译工具

Transly是一个多场景的AI大语言模型驱动的同声传译、专业翻译助手,它拥有超精准的音频识别翻译能力,几乎零延迟的使用体验和支持多国语言可以让你带它走遍全球,无论你是留学生、商务人士、韩剧美剧爱好者,还是出国游玩、多国会议、跨国追星等等,都可以满足你所有需要同传的场景需求,线上线下通用,扫除语言障碍,让全世界的语言交流不再有国界。

讯飞智�文

讯飞智文

一键生成PPT和Word,让学习生活更轻松

讯飞智文是一个利用 AI 技术的项目,能够帮助用户生成 PPT 以及各类文档。无论是商业领域的市场分析报告、年度目标制定,还是学生群体的职业生涯规划、实习避坑指南,亦或是活动策划、旅游攻略等内容,它都能提供支持,帮助用户精准表达,轻松呈现各种信息。

AI办公办公工具AI工具讯飞智文AI在线生成PPTAI撰写助手多语种文档生成AI自动配图热门
讯飞星火

讯飞星火

深度推理能力全新升级,全面对标OpenAI o1

科大讯飞的星火大模型,支持语言理解、知识问答和文本创作等多功能,适用于多种文件和业务场景,提升办公和日常生活的效率。讯飞星火是一个提供丰富智能服务的平台,涵盖科技资讯、图像创作、写作辅助、编程解答、科研文献解读等功能,能为不同需求的用户提供便捷高效的帮助,助力用户轻松获取信息、解决问题,满足多样化使用场景。

热门AI开发模型训练AI工具讯飞星火大模型智能问答内容创作多语种支持智慧生活
Spark-TTS

Spark-TTS

一种基于大语言模型的高效单流解耦语音令牌文本到语音合成模型

Spark-TTS 是一个基于 PyTorch 的开源文本到语音合成项目,由多个知名机构联合参与。该项目提供了高效的 LLM(大语言模型)驱动的语音合成方案,支持语音克隆和语音创建功能,可通过命令行界面(CLI)和 Web UI 两种方式使用。用户可以根据需求调整语音的性别、音高、速度等参数,生成高质量的语音。该项目适用于多种场景,如有声读物制作、智能语音助手开发等。

咔片PPT

咔片PPT

AI助力,做PPT更简单!

咔片是一款轻量化在线演示设计工具,借助 AI 技术,实现从内容生成到智能设计的一站式 PPT 制作服务。支持多种文档格式导入生成 PPT,提供海量模板、智能美化、素材替换等功能,适用于销售、教师、学生等各类人群,能高效制作出高品质 PPT,满足不同场景演示需求。

讯飞绘文

讯飞绘文

选题、配图、成文,一站式创作,让内容运营更高效

讯飞绘文,一个AI集成平台,支持写作、选题、配图、排版和发布。高效生成适用于各类媒体的定制内容,加速品牌传播,提升内容营销效果。

热门AI辅助写作AI工具讯飞绘文内容运营AI创作个性化文章多平台分发AI助手
材料星

材料星

专业的AI公文写作平台,公文写作神器

AI 材料星,专业的 AI 公文写作辅助平台,为体制内工作人员提供高效的公文写作解决方案。拥有海量公文文库、9 大核心 AI 功能,支持 30 + 文稿类型生成,助力快速完成领导讲话、工作总结、述职报告等材料,提升办公效率,是体制打工人的得力写作神器。

下拉加载更多