Skip to content

Commit

Permalink
[mailhog] Add Outgoing SMTP config (#409)
Browse files Browse the repository at this point in the history
* Add outgoing-smtp secret and values
* Docs
* Bump chart version
* Do not use default values for outgoingSMTP.fileContents

Co-authored-by: Rainer 'rei' Schuth <[email protected]>
Co-authored-by: mircohaug <[email protected]>
  • Loading branch information
3 people authored Apr 9, 2021
1 parent d72b242 commit eb8255f
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion charts/mailhog/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
description: An e-mail testing tool for developers
name: mailhog
appVersion: v1.0.1
version: 4.0.0
version: 4.1.0
type: application
keywords:
- mailhog
Expand Down
11 changes: 11 additions & 0 deletions charts/mailhog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,14 @@ Create the name for the auth secret.
{{- template "mailhog.fullname" . -}}-auth
{{- end -}}
{{- end -}}

{{/*
Create the name for the outgoing-smtp secret.
*/}}
{{- define "mailhog.outgoingSMTPSecret" -}}
{{- if .Values.outgoingSMTP.existingSecret -}}
{{- .Values.outgoingSMTP.existingSecret -}}
{{- else -}}
{{- template "mailhog.fullname" . -}}-outgoing-smtp
{{- end -}}
{{- end -}}
16 changes: 16 additions & 0 deletions charts/mailhog/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ spec:
- name: MH_AUTH_FILE
value: /authdir/{{ .Values.auth.fileName }}
{{- end }}
{{- if .Values.outgoingSMTP.enabled }}
- name: MH_OUTGOING_SMTP
value: /config/{{ .Values.outgoingSMTP.fileName }}
{{- end }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
Expand All @@ -68,6 +72,12 @@ spec:
mountPath: /authdir
readOnly: true
{{- end }}
{{- if .Values.outgoingSMTP.enabled }}
volumeMounts:
- name: outsmtpdir
mountPath: /config
readOnly: true
{{- end }}
{{- with .Values.containerSecurityContext }}
securityContext:
{{- toYaml . | nindent 12 }}
Expand All @@ -92,3 +102,9 @@ spec:
secret:
secretName: {{ template "mailhog.authFileSecret" . }}
{{- end }}
{{- if .Values.outgoingSMTP.enabled }}

This comment has been minimized.

Copy link
@pflechat

pflechat Jun 25, 2021

If outgoingSMTP.enabled and auth.enabled are both true, the outgoingSMTP volumes and volumeMounts overwrite the auth ones and the pods doesn't start because they don't find the unmounted auth file

volumes:
- name: outsmtpdir
secret:
secretName: {{ template "mailhog.outgoingSMTPSecret" . }}
{{- end }}
12 changes: 12 additions & 0 deletions charts/mailhog/templates/smtp-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{{- if and (.Values.outgoingSMTP.enabled) (not .Values.outgoingSMTP.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
labels:
{{- include "mailhog.labels" . | nindent 4 }}
name: {{ template "mailhog.outgoingSMTPSecret" . }}
namespace: {{ .Release.Namespace }}
type: Opaque
data:
{{ .Values.outgoingSMTP.fileName }}: {{ .Values.outgoingSMTP.fileContents | toJson | b64enc }}
{{- end -}}
22 changes: 22 additions & 0 deletions charts/mailhog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,28 @@ auth:
fileName: auth.txt
fileContents: ""

# JSON file defining outgoing SMTP servers
outgoingSMTP:
enabled: false
existingSecret: ""
fileName: outgoing-smtp.json
fileContents: {}
# See https://github.com/mailhog/MailHog/blob/master/docs/CONFIG.md#outgoing-smtp-configuration
# Only name, host and port are required.
#
# server_name1:
# name: "server_name1"
# host: "mail.example.com"
# port: "25" # NOTE: go requires this port number to be a string... otherwise the container won't start
# email: ""
# username: ""
# password: ""
# mechanism: "PLAIN|CRAM-MD5"
# server_name2:
# name: "server_name2"
# host: "mail2.example.com"
# port: "587" # NOTE: go requires this port number to be a string... otherwise the container won't start

podAnnotations: {}

podLabels: {}
Expand Down

0 comments on commit eb8255f

Please sign in to comment.