mail

by bokysan

Helm chartv5.2.1App 5.2.1MITVerified publisher

An outgoing SMTP mail relay for your applications in Kubernetes cluster

About this chart

docker-postfix

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.

Star History

Table of contents

  • docker-postfix
    • Table of contents
    • Description
    • TL;DR
    • Updates
      • v6.0.0
      • v5.0.0
      • v4.0.0
      • v3.0.0
    • Architectures
    • Configuration options
      • General options
        • Inbound debugging
        • ALLOWED_SENDER_DOMAINS and ALLOW_EMPTY_SENDER_DOMAINS
        • AUTOSET_HOSTNAME and AUTOSET_HOSTNAME_SERVICES
        • Log format
      • Postfix-specific options
        • RELAYHOST, RELAYHOST_USERNAME and RELAYHOST_PASSWORD
        • POSTFIX_smtp_tls_security_level
        • XOAUTH2_CLIENT_ID, XOAUTH2_SECRET, XOAUTH2_INITIAL_ACCESS_TOKEN, XOAUTH2_INITIAL_REFRESH_TOKEN and XOAUTH2_TOKEN_ENDPOINT
          • OAuth2 Client Credentials (GMail)
          • Obtain Initial Access Token (GMail)
          • Debug XOAuth2 issues
        • MASQUERADED_DOMAINS
        • SMTP_HEADER_CHECKS
        • POSTFIX_myhostname
        • POSTFIX_mynetworks
        • POSTFIX_message_size_limit
        • Overriding specific postfix settings
        • SKIP_ROOT_SPOOL_CHOWN
        • ANONYMIZE_EMAILS
          • The default (smart) filter
          • The paranoid filter
          • The hash filter
          • The noop filter
          • Writing your own filters
      • DKIM / DomainKeys
        • Choosing the DKIM backend (DKIM_BACKEND)
        • Migrating from OpenDKIM to rspamd
        • Supplying your own DKIM keys
        • Auto-generating the DKIM selectors through the image
        • Changing the DKIM selector
        • Overriding specific rspamd settings
        • Overriding specific OpenDKIM settings
        • Verifying your DKIM setup
      • Docker Secrets / Kubernetes secrets
    • Helm chart
      • Metrics
    • Extending the image
      • Using custom init scripts
    • Security
      • UIDs/GIDs numbers
    • Quick how-tos
      • Relaying messages through your Gmail account
      • Relaying messages through Google Apps account
      • Relaying messages through Amazon's SES
      • Sending messages directly
        • Careful
    • Similar projects
    • License check

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
docker run --rm --name postfix -e "ALLOWED_SENDER_DOMAINS=example.com" -p 1587:587 ghcr.io/bokysan/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
# or, using the OCI registry:
helm upgrade --install --set persistence.enabled=false --set config.general.ALLOW_EMPTY_SENDER_DOMAINS=yes mail oci://ghcr.io/bokysan/charts/mail

You can also find the Helm chart 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

v6.0.0

DKIM signing

The default DKIM backend has changed from OpenDKIM to rspamd.

For most users this transition is automatic and requires no action:

  • On first startup with the new default, any DKIM keys found under /etc/opendkim/keys are automatically imported into rspamd (see DKIM / DomainKeys). Your existing keys are copied (not moved), so nothing is lost and you can switch back.
  • rspamd signs using relaxed/relaxed canonicalization. Your published DNS records remain valid -- there is no need to regenerate keys or update DNS.
  • Postfix is now wired to rspamd's milter (inet:localhost:11332) instead of OpenDKIM's (inet:localhost:8891).

If you are not ready to migrate, set DKIM_BACKEND=opendkim to keep using OpenDKIM. OpenDKIM is deprecated and will be removed in a future major release, so please plan your migration.

If you run the image with a read-only root filesystem, note that rspamd needs two writable paths: /etc/rspamd and /var/lib/rspamd. Mount them (e.g. as emptyDir / tmpfs) -- see the read-only image examples.

Custom rspamd settings are configured with RSPAMD_<file>__<key> environment variables (see Overriding specific rspamd settings).

Helm chart validation

helm chart now includes validation through values.schema.json.

Version alignment

v versions of helm charts have been dropped. SemVer-s are now more aligned with the standard.

Bugfixes

Better support for read-only root images, postfix-exporter has been migrated to Hsn723's version which is more current and being kept up to date.

v5.0.0

Image has been updated to Debian Trixie and with that linux/mips64le is gone. To prevent failures during upgrade, major version has been bumped. New versions of go do not provide images for linux/arm/v5 and it's not really supported that well on Debian any more, so this architecture is dropped as well.

Several other fixes went into this release as well. Full list is available on the releases page.

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/arm/v7, linux/arm64/v8, linux/amd64, linux/arm64, 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 (otherwi

Deploy mail with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has mail on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartmail is pinned at v5.2.1 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply