From 9fa2b2d1b786edd1b8acf4bc59d94a140568b34f Mon Sep 17 00:00:00 2001 From: decentral1se Date: Wed, 2 Jun 2021 08:24:33 +0200 Subject: [PATCH] Support SMTP relay configuration Hopefully this doesn't bork existing relay configs --- .env.sample | 4 ++++ abra.sh | 2 +- compose.mailrelay.yml | 10 ++++++++++ msmtp.conf.tmpl | 11 +++++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/.env.sample b/.env.sample index 3c94b19..b98f7fe 100644 --- a/.env.sample +++ b/.env.sample @@ -32,4 +32,8 @@ SECRET_DB_PASSWORD_VERSION=v1 # SMTP #COMPOSE_FILE="compose.yml:compose.mailrelay.yml" #SMTP_HOST="postfix_relay_app" +#SMTP_PORT=587 +#SMTP_AUTH=on +#SMTP_TLS=on #MAIL_FROM="wordpress@example.com" +#SECRET_SMTP_PASSWORD_VERSION=v1 diff --git a/abra.sh b/abra.sh index 56d32a7..8b65a43 100644 --- a/abra.sh +++ b/abra.sh @@ -1,7 +1,7 @@ export PHP_UPLOADS_CONF_VERSION=v3 export ENTRYPOINT_CONF_VERSION=v2 export ENTRYPOINT_MAILRELAY_CONF_VERSION=v1 -export MSMTP_CONF_VERSION=v1 +export MSMTP_CONF_VERSION=v2 sub_wp() { CONTAINER=$(docker container ls -f "Name=${STACK_NAME}_app" --format '{{ .ID }}') diff --git a/compose.mailrelay.yml b/compose.mailrelay.yml index ad686d8..89f0779 100644 --- a/compose.mailrelay.yml +++ b/compose.mailrelay.yml @@ -4,8 +4,13 @@ version: "3.8" services: app: entrypoint: /docker-entrypoint.mailrelay.sh + secrets: + - smtp_password environment: - SMTP_HOST=${SMTP_HOST} + - SMTP_PORT=${SMTP_PORT} + - SMTP_AUTH=${SMTP_AUTH} + - SMTP_TLS=${SMTP_TLS} - MAIL_FROM=${MAIL_FROM} configs: - source: mstmp_conf @@ -23,3 +28,8 @@ configs: name: ${STACK_NAME}_entrypoint_mailrelay_${ENTRYPOINT_MAILRELAY_CONF_VERSION} file: entrypoint.mailrelay.sh.tmpl template_driver: golang + +secrets: + smtp_password: + name: ${STACK_NAME}_smtp_password_${SECRET_SMTP_PASSWORD_VERSION} + external: true diff --git a/msmtp.conf.tmpl b/msmtp.conf.tmpl index f240920..5ea09ce 100644 --- a/msmtp.conf.tmpl +++ b/msmtp.conf.tmpl @@ -1,3 +1,14 @@ account default host {{ env "SMTP_HOST" }} from {{ env "MAIL_FROM" }} +port {{ env "SMTP_PORT" }} + +{{ if eq (env "SMTP_AUTH") "on" }} +auth {{ env "SMTP_AUTH" }} +passwordeval "cat /run/secrets/smtp_password" +{{ end }} + +{{ if eq (env "SMTP_TLS") "on" }} +tls {{ env "SMTP_TLS" }} +tls_trust_file /etc/ssl/certs/ca-certificates.crt +{{ end }}