smtp2x

by wenisch.tech

Helm chartv0.5.8App 0.5.8AGPL-3.0

SMTP notifications to GitLab issues and webhooks

About this chart

SMTP2X Helm chart

This chart deploys SMTP2X with separate HTTP and SMTP Services, persistent storage, health probes, optional HTTP ingress, and environment-based application configuration.

Install

helm install smtp2x ./charts/smtp2x \
  --namespace smtp2x \
  --create-namespace \
  --set-string secrets.SMTP2X_ADMIN_PASSWORD='change-me-now'

SMTP2X uses a local H2 database and persistent volume by default. replicaCount must remain 1 because message attachments are stored on the pod's persistent volume. The chart uses a Recreate update strategy so an updated pod never starts against the same H2 data directory as the old one. The SMTP and HTTP Services default to ClusterIP; the HTTP Service is intended for ingress access.

The application exposes /actuator/health, /actuator/health/liveness, and /actuator/health/readiness. The startup probe allows 150 seconds for the JVM, Flyway migration, and SMTP listener to start before Kubernetes evaluates liveness. A failed readiness probe only removes the pod from Services; a failed startup or liveness probe restarts it.

The HTTP Service is annotated for Prometheus scraping at /actuator/prometheus by default. Disable discovery with metrics.serviceAnnotations.enabled=false, or change the advertised path with metrics.path.

Existing Kubernetes Secret

Set externalSecretName to import every key from an existing Secret as a container environment variable. This works with a Secret maintained by OpenBao, Vault, an external-secrets operator, or another controller:

externalSecretName: smtp2x-runtime

The Secret must exist in the SMTP2X release namespace. Its keys must be valid environment variable names, for example SMTP2X_ADMIN_PASSWORD or SPRING_DATASOURCE_PASSWORD. Values configured through env or the chart-managed secrets map take precedence over duplicate keys imported through externalSecretName.

Ingress

The ingress follows the same host/path structure as the Kairos chart and forwards HTTP traffic to the SMTP2X HTTP Service. This example enables HTTPS with nginx and cert-manager:

ingress:
  enabled: true
  className: nginx
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt
  hosts:
    - host: smtp2x.example.com
      paths:
        - path: /
          pathType: Prefix
  tls:
    - secretName: smtp2x-tls
      hosts:
        - smtp2x.example.com

Install these values from a file with helm upgrade --install smtp2x ./charts/smtp2x -f values-production.yaml.

The ingress covers the web application only. Expose SMTP through service.smtp, or through the TCP configuration of your ingress controller. If SMTP CIDR allowlists are enabled, make sure the load balancer preserves the client address.

OIDC through environment variables

SMTP2X uses the Spring Security OAuth2 client named keycloak. Every part of its OIDC configuration can be supplied as an environment variable through env and secrets:

env:
  SMTP2X_SECURITY_OIDC_ENABLED: "true"
  SMTP2X_SECURITY_OIDC_ROLE_MAPPING_ENABLED: "true"
  OIDC_IGNORE_TLS: "false"
  SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_CLIENT_ID: smtp2x
  SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_SCOPE: openid,profile,email
  SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_KEYCLOAK_ISSUER_URI: https://auth.example.com/realms/smtp2x
secrets:
  SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_CLIENT_SECRET: replace-me

The corresponding command-line form is:

helm upgrade --install smtp2x ./charts/smtp2x \
  --namespace smtp2x --create-namespace \
  --set-string env.SMTP2X_SECURITY_OIDC_ENABLED=true \
  --set-string env.SMTP2X_SECURITY_OIDC_ROLE_MAPPING_ENABLED=true \
  --set-string env.SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_CLIENT_ID=smtp2x \
  --set-string env.SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_SCOPE=openid,profile,email \
  --set-string env.SPRING_SECURITY_OAUTH2_CLIENT_PROVIDER_KEYCLOAK_ISSUER_URI=https://auth.example.com/realms/smtp2x \
  --set-string secrets.SPRING_SECURITY_OAUTH2_CLIENT_REGISTRATION_KEYCLOAK_CLIENT_SECRET=replace-me

Register this redirect URI with the OIDC provider:

https://smtp2x.example.com/login/oauth2/code/keycloak

The ingress must preserve X-Forwarded-Proto, X-Forwarded-Host, and X-Forwarded-Port. SMTP2X already enables Spring's forwarded-header support so it generates the public HTTPS callback URL.

New OIDC users without a matching role start with the PENDING role. When role mapping is enabled, SMTP2X_Admin and ROLE_SMTP2X_ADMIN map to Admin, while SMTP2X_Viewer and ROLE_SMTP2X_VIEWER map to Viewer. Matching is case-insensitive.

For temporary troubleshooting with a private or self-signed issuer certificate, set env.OIDC_IGNORE_TLS to "true". This disables certificate and hostname verification for OIDC discovery, token exchange, and JWK retrieval. Install the issuer CA in the container trust store for production deployments instead.

PostgreSQL

Activate the PostgreSQL profile and pass the datasource settings as environment variables:

env:
  SPRING_PROFILES_ACTIVE: postgres
  SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/smtp2x
  SPRING_DATASOURCE_USERNAME: smtp2x
secrets:
  SPRING_DATASOURCE_PASSWORD: replace-me

Values

ValueDefaultDescription
image.repositoryghcr.io/wenisch-tech/smtp2xContainer image repository
image.tagChart app versionContainer tag; an empty value uses appVersion
image.pullPolicyIfNotPresentKubernetes image pull policy
replicaCount1Deployment replicas
updateStrategy.typeRecreateDeployment update strategy for the single-writer H2 volume
securityContextSee values.yamlContainer privilege settings
service.http.typeClusterIPHTTP Service type
service.http.port8080HTTP Service port
service.smtp.typeClusterIPSMTP Service type
service.smtp.port2525SMTP Service port
metrics.path/actuator/prometheusPrometheus scrape path
metrics.serviceAnnotations.enabledtrueAdd Prometheus scrape annotations to the HTTP Service
ingress.enabledfalseCreate an HTTP Ingress
ingress.classNameemptyIngress class name
ingress.annotations{}Ingress annotations
ingress.hostssmtp2x.example.comIngress hosts and paths
ingress.tls[]TLS hosts and Secret names
persistence.enabledtrueCreate a PVC for /app/data
persistence.storageClassNameemptyStorage class, or the cluster default
persistence.size10GiRequested storage size
resourcesSee values.yamlContainer requests and limits
startupProbeSee values.yamlStartup health probe; delays liveness until startup succeeds
livenessProbeSee values.yamlLiveness probe; failures restart the container
readinessProbeSee values.yamlReadiness probe; failures remove the pod from Services
externalSecretNameemptyExisting Kubernetes Secret imported with envFrom
env.OIDC_IGNORE_TLS"false"Temporarily disable OIDC certificate and hostname verification
envSee values.yamlPlain environment variables
secrets{}Secret-backed environment variables

When the same variable exists in both env and secrets, the Secret-backed value takes precedence.

The chart validates supplied values against values.schema.json during Helm install, upgrade, lint, and template operations.

Deploy smtp2x with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has smtp2x 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 chartsmtp2x is pinned at v0.5.8 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