maildev

by christianhuth

Helm chartv1.7.1App 2.2.1Verified publisher

MailDev is a simple way to test your emails during development with an easy to use web interface.

About this chart

maildev

MailDev is a simple way to test your emails during development with an easy to use web interface.

TL;DR;

helm repo add christianhuth https://charts.christianhuth.de
helm repo update
helm install my-release christianhuth/maildev

Or install it from the OCI registry:

helm install my-release oci://ghcr.io/christianhuth/helm-charts/maildev

Introduction

This chart bootstraps MailDev on a Kubernetes cluster using the Helm package manager.

MailDev is a simple way to test your project's generated emails during development with an easy-to-use web interface that runs on your machine.

Its main usage is to provide you with a SMTP relay service inside Kubernetes, so other apps can rely on it to send mails externally.

Inside the Namespace where it is deployed, an SMTP service is available: RELEASE_NAME-smtp:1025. To make the SMTP service available for applications running outside of Kubernetes you can set services.smtp.type to NodePort.

MailDev also provides a Web interface, it can be disabled/enabled using maildev.config.web.disabled.

Prerequisites

  • Kubernetes 1.19+

Installing the Chart

To install the chart with the release name my-release:

helm repo add christianhuth https://charts.christianhuth.de
helm repo update
helm install my-release christianhuth/maildev

The chart is also published as an OCI artifact which can be installed like this:

helm install my-release oci://ghcr.io/christianhuth/helm-charts/maildev

These commands deploy MailDev on the Kubernetes cluster in the default configuration. The Values section lists the values that can be configured during installation.

Tip: List all releases using helm list

Test it

Forward your local port to the pod (this will block your terminal, open an additional one).

kubectl port-forward $(kubectl get pod -l "app.kubernetes.io/name=maildev" -o name) 1025

Create dummy mail.txt file.

cat <<EOF >> mail.txt
From: Test Maildev <[email protected]>
To: Nikola Tesla Tudela <[email protected]>
Subject: Test mail from command line
Date: Fri, 17 Nov 2020 11:26:16

Dear Joe,
Welcome to this example email. What a lovely day.
Cheers!!
EOF

Send the mail with curl:

curl smtp://localhost:1025 --mail-from [email protected] --mail-rcpt [email protected] --upload-file ./mail.txt

The mail should now show up in your inbox.

If you have enabled the logs for mails using maildev.config.logMailContents=true, you can also check the logs and see if the mail has been delivered.

kubectl logs $(kubectl get pod -l "app.kubernetes.io/name=maildev" -o name)

Output should be something like:

MailDev webapp running at http://0.0.0.0:1080
MailDev SMTP Server running at 0.0.0.0:1025
Received the following mail contents.

Uninstalling the Chart

To uninstall the my-release deployment:

helm uninstall my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Values

KeyTypeDefaultDescription
affinityobject{}Affinity settings for pod assignment
autoscaling.enabledboolfalseEnable Horizontal POD autoscaling
autoscaling.maxReplicasint100Maximum number of replicas
autoscaling.minReplicasint1Minimum number of replicas
autoscaling.targetCPUUtilizationPercentageint80Target CPU utilization percentage
autoscaling.targetMemoryUtilizationPercentageint80Target Memory utilization percentage
deploymentStrategyobject{}Update strategy for the deployment. Set type: Recreate if the persistence uses ReadWriteOnce volumes, as a rolling update starts the new Pod before stopping the old one and it can't mount the volume on another node.
extraEnvlist[]additional environment variables to be added to the pods
fullnameOverridestring""String to fully override "maildev.fullname"
image.pullPolicystring"Always"image pull policy
image.registrystring"docker.io"image registry
image.repositorystring"maildev/maildev"image repository
image.tagstring"2.2.1"Overrides the image tag
imagePullSecretslist[]If defined, uses a Secret to pull an image from a private Docker registry or repository.
ingress.annotationsobject{}Additional annotations for the Ingress resource
ingress.classNamestring""IngressClass that will be be used to implement the Ingress
ingress.enabledboolfalseEnable ingress record generation
ingress.hostslistsee values.yamlAn array with hosts and paths
ingress.tlslist[]An array with the tls configuration
maildev.config.https.certstring""The ssl cert file
maildev.config.https.enabledboolfalseSwitch from http to https protocol
maildev.config.https.keystring""The ssl private key
maildev.config.logMailContentsboolfalseLog a JSON representation of each incoming mail
maildev.config.mailDirectorystring"/home/node/maildev-data"Directory for persisting mail
maildev.config.modes.silentbooltrueRun maildev in silent mode to disable the startup messages
maildev.config.modes.verboseboolfalseRun maildev in verbose mode
maildev.config.smtp.hideExtensionsstring""Comma separated list of SMTP extensions to NOT advertise (SMTPUTF8, PIPELINING, 8BITMIME)
maildev.config.smtp.incoming.existingSecretstring""Name of an existing secret containing the password for the incoming SMTP mail. If set maildev.config.smtp.incoming.password will be ignored. Key needs to be smtp-incoming-password.
maildev.config.smtp.incoming.passwordstring""SMTP password for incoming mail
maildev.config.smtp.incoming.tls.certstring""Cert for incoming SSL
maildev.config.smtp.incoming.tls.enabledboolfalseUse SMTP SSL for incoming emails
maildev.config.smtp.incoming.tls.existingSecretstring""Name of an existing TLS secret containing the cert and key for the incoming SMTP mail. If set maildev.config.smtp.incoming.tls.cert and maildev.config.smtp.incoming.tls.key will be ignored. Keys need to be tls.crt and tls.key.
maildev.config.smtp.incoming.tls.keystring""Key for incoming SSL
maildev.config.smtp.incoming.usernamestring""SMTP user for incoming mail
maildev.config.smtp.outgoing.autoRelay.enabledboolfalseEnabling the auto relay mode will automatically send each email to it's recipient without the need to click the "Relay" button. The outgoing email options are required to enable this feature.
maildev.config.smtp.outgoing.autoRelay.mailstring""Optionally define a single email address which Maildev will forward all emails to instead of the original recipient
maildev.config.smtp.outgoing.autoRelay.ruleslist[]The additional configuration for what email addresses you would like to allow or deny.
maildev.config.smtp.outgoing.existingSecretstring""Name of an existing secret containing the password for the outgoing SMTP mail. If set maildev.config.smtp.outgoing.password will be ignored. Key needs to be smtp-outgoing-password.
maildev.config.smtp.outgoing.hoststring""SMTP host for outgoing mail
maildev.config.smtp.outgoing.passwordstring""SMTP password for outgoing mail
maildev.config.smtp.outgoing.portint25SMTP port for outgoing mail
maildev.config.smtp.outgoing.sslboolfalseUse SMTP SSL for outgoing mail
maildev.config.smtp.outgoing.usernamestring""SMTP user for outgoing mail
maildev.config.web.disabledboolfalseDisable the use of the web interface. Useful for unit testing
maildev.config.web.existingSecretstring""Name of an existing secret containing the password for the GUI. If set maildev.config.web.password will be ignored. Key needs to be web-password.
maildev.config.web.passwordstring""Password for the GUI
maildev.config.web.usernamestring""Username for the GUI
maildev.persistence.accessModeslist["ReadWriteOnce"]The desired access modes the volume should have.
maildev.persistence.annotationsobject{}Annotations to be added to the PersistentVolumeClaim
maildev.persistence.cron.config.daysToKeepint15How old emails may be before they get deleted
maildev.persistence.cron.config.schedulestring"0 1 * * *"The schedule on which the cronjob should run
maildev.persistence.cron.enabledboolfalseEnable the creation of a cronjob to periodically delete old emails
maildev.persistence.cron.image.pullPolicystring"Always"Image pull policy
maildev.persistence.cron.image.registrystring"docker.io"Image registry
maildev.persistence.cron.image.repositorystring"busybox"Image repository
maildev.persistence.cron.image.tagstring"latest"Overrides the image tag
maildev.persistence.enabledboolfalseUse a PVC to persist data
maildev.persistence.existingClaimstring""Provide an existing PersistentVolumeClaim
maildev.persistence.resourcesobject{"requests":{"storage":"2Gi"}}Represents the minimum and maximum resources the volume should have.
maildev.persistence.storageClassNamestring""Name of the StorageClass required by the claim.
nameOverridestring""Provide a name in place of maildev
nodeSelectorobject{}Node labels for pod assignment
podAnnotationsobject{}Annotations to be added to the pods
podSecurityContextobject{}pod-level security context
replicaCountint1Number of replicas
resourcesobject{}Resource limits and requests for the controller pods.
revisionHistoryLimitint10The number of old ReplicaSets to retain
route.main.additionalRuleslist[]Additional custom rules that can be added to the route
route.main.annotationsobject{}Add annotations to the route
route.main.apiVersionstring"gateway.networking.k8s.io/v1"Set the route apiVersion, e.g. gateway.networking.k8s.io/v1 or gateway.networking.k8s.io/v1alpha2
route.main.enabledboolfalseEnables or disables the route
route.main.filterslist[]Filters define the filters that are applied to requests that match this rule.
route.main.hostnameslist[]Hostnames to be matched
route.main.httpsRedirectboolfalseadds a filter for redirecting to https (HTTP 301 Moved Permanently). To redirect HTTP traffic to HTTPS, you need to have a Gateway with both HTTP and HTTPS listeners. Matches and filters do not take effect if enabled. Ref. https://gateway-api.sigs.k8s.io/guides/http-redirect-rewrite/
route.main.kindstring"HTTPRoute"Set the route kind Valid options are GRPCRoute, HTTPRoute, TCPRoute, TLSRoute, UDPRoute
route.main.labelsobject{}Add labels to the route
route.main.matcheslistsee values.yamldefine conditions used for matching the rule against incoming HTTP requests.
route.main.parentRefslist[]Parent references (Gateway)
route.main.timeoutsobject{}defines the timeouts that can be configured for an HTTP request
securityContextobject{}container-level security context
serviceAccount.annotationsobject{}Annotations to add to the service account
serviceAccount.createbooltrueSpecifies whether a service account should be created
serviceAccount.namestring""The name of the service account to use. If not set and create is true, a name is generated using the fullname template
services.smtp.nodePortint0You can set the node port for the external SMTP server that should be used or leave it blank to get a random node port. Only active if services.smtp.type == NodePort
services.smtp.podPortint1025Pod port to use for the internal SMTP server
services.smtp.portint1025Kubernetes service port to use for the internal SMTP server
services.smtp.typestring"ClusterIP"Kubernetes service type for the SMTP server
services.web.podPortint1080Pod port to use for the web GUI
services.web.portint1080Kubernetes service port to use for the web GUI
services.web.typestring"ClusterIP"Kubernetes service type for the web GUI
tolerationslist[]Toleration labels for pod assignment

Specify each parameter using the --set key=value[,key=value] argument to helm install.

Alternatively, a YAML file that specifies the values for the parameters can be provided while installing the chart. For example,

helm install my-release -f values.yaml christianhuth/maildev

Deploy maildev with OpenTenant

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