diff --git a/.envrc.sample b/.envrc.sample index dac0ff9..43b68a1 100644 --- a/.envrc.sample +++ b/.envrc.sample @@ -26,3 +26,9 @@ export DB_PASSWORD_VERSION=v1 # Backups #export COMPOSE_FILE="compose.yml:compose.backup.yml" + +# SMTP +#export COMPOSE_FILE="compose.yml:compose.mailrelay.yml" +#export SMTP_HOST="postfix_relay_app" +#export MSMTP_CONF_VERSION=v1 +#export ENTRYPOINT_MAILRELAY_CONF_VERSION=v1 diff --git a/compose.mailrelay.yml b/compose.mailrelay.yml new file mode 100644 index 0000000..81725a1 --- /dev/null +++ b/compose.mailrelay.yml @@ -0,0 +1,31 @@ +--- +version: "3.8" + +services: + wordpress: + entrypoint: /docker-entrypoint2.sh + environment: + - SMTP_HOST=${SMTP_HOST} + networks: + - mail + configs: + - source: entrypoint_mailrelay_conf + target: /docker-entrypoint2.sh + mode: 0555 + - source: mstmp_conf + target: /etc/msmtprc + mode: 0555 + +networks: + mail: + external: true + +configs: + mstmp_conf: + name: ${STACK_NAME}_mstmp_conf_${MSMTP_CONF_VERSION} + file: msmtp.conf.tmpl + template_driver: golang + entrypoint_mailrelay_conf: + name: ${STACK_NAME}_entrypoint_mailrelay_${ENTRYPOINT_MAILRELAY_CONF_VERSION} + file: entrypoint.mailrelay.sh.tmpl + template_driver: golang diff --git a/entrypoint.mailrelay.sh.tmpl b/entrypoint.mailrelay.sh.tmpl new file mode 100644 index 0000000..e65f652 --- /dev/null +++ b/entrypoint.mailrelay.sh.tmpl @@ -0,0 +1,9 @@ +#!/bin/bash + +apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y msmtp && rm -rf /var/lib/apt/lists/* + +echo "sendmail_path = /usr/bin/msmtp -t -i" >> /usr/local/etc/php/conf.d/sendmail.ini + +# Upstream ENTRYPOINT +# https://github.com/docker-library/wordpress/blob/master/php7.4/apache/Dockerfile#L120 +/usr/local/bin/docker-entrypoint.sh apache2-foreground "$@" diff --git a/msmtp.conf.tmpl b/msmtp.conf.tmpl new file mode 100644 index 0000000..991a6b9 --- /dev/null +++ b/msmtp.conf.tmpl @@ -0,0 +1,3 @@ +account default +host {{ env "SMTP_HOST" }} +auto_from on