From 40d95417e94bd11d091c27ecf584672545c38375 Mon Sep 17 00:00:00 2001 From: 3wc <3wc@doesthisthing.work> Date: Mon, 23 Oct 2023 10:26:10 +0100 Subject: [PATCH] Improve SMTP settings --- .env.sample | 2 ++ abra.sh | 2 +- compose.smtp.yml | 9 +++++---- msmtp.conf.tmpl | 6 +++++- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.env.sample b/.env.sample index 00581da..5fd9145 100644 --- a/.env.sample +++ b/.env.sample @@ -46,6 +46,8 @@ SECRET_DB_PASSWORD_VERSION=v1 #COMPOSE_FILE="$COMPOSE_FILE:compose.smtp.yml" #SMTP_HOST="mail.example.com" #MAIL_FROM="wordpress@example.com" +#SMTP_USER="wordpress@example.com" # optional, defaults to MAIL_FROM +#SMTP_OVERRIDE_FROM=on # force "From" to MAIL_FROM, usually necessary #SMTP_PORT=587 #SMTP_AUTH=on #SMTP_TLS=on diff --git a/abra.sh b/abra.sh index 3dbfb19..9d2472f 100644 --- a/abra.sh +++ b/abra.sh @@ -1,7 +1,7 @@ export PHP_UPLOADS_CONF_VERSION=v3 export ENTRYPOINT_CONF_VERSION=v4 export ENTRYPOINT_MAILRELAY_CONF_VERSION=v2 -export MSMTP_CONF_VERSION=v3 +export MSMTP_CONF_VERSION=v4 wp() { su -p www-data -s /bin/bash -c "/usr/local/bin/wp $@" diff --git a/compose.smtp.yml b/compose.smtp.yml index 134fffe..bb62d6a 100644 --- a/compose.smtp.yml +++ b/compose.smtp.yml @@ -6,11 +6,12 @@ services: secrets: - smtp_password environment: - - SMTP_HOST=${SMTP_HOST} + - SMTP_HOST - SMTP_PORT=${SMTP_PORT:-25} - - SMTP_AUTH=${SMTP_AUTH} - - SMTP_TLS=${SMTP_TLS} - - MAIL_FROM=${MAIL_FROM} + - SMTP_AUTH + - SMTP_TLS + - MAIL_FROM + - SMTP_OVERRIDE_FROM secrets: smtp_password: diff --git a/msmtp.conf.tmpl b/msmtp.conf.tmpl index 2c6fb33..aad889b 100644 --- a/msmtp.conf.tmpl +++ b/msmtp.conf.tmpl @@ -1,9 +1,13 @@ account default host {{ env "SMTP_HOST" }} from {{ env "MAIL_FROM" }} -user {{ env "MAIL_FROM" }} +user {{ or (env "SMTP_USER") (env "MAIL_FROM") }} port {{ env "SMTP_PORT" }} +{{ if eq (env "SMTP_OVERRIDE_FROM") "on" }} +set_from_header on +{{ end }} + {{ if eq (env "SMTP_AUTH") "on" }} auth {{ env "SMTP_AUTH" }} passwordeval "cat /run/secrets/smtp_password"