Files
wordpress-stack/docker/wordpress/scripts/docker-entrypoint.d/05-install-msmtp.sh
2025-12-29 17:28:49 -03:00

65 lines
1.3 KiB
Bash

# Instals msmtp if a SMTP_HOST var was configured
if test -n "${SMTP_HOST}"; then
apk add --no-cache msmtp;
if test -z "${SMTP_PORT:-}"; then
if test "${SMTP_TLS:-on}" = "off"; then
SMTP_PORT=25;
elif test "${SMTP_TLS:-on}" = "starttls"; then
SMTP_PORT=587;
else
SMTP_PORT=465;
fi
fi
echo "**** SMTP_AUTH=${SMTP_AUTH:-<empty>}";
if test "${SMTP_AUTH:-on}" = "off"; then
SMTP_TLS="off";
fi
cat > /etc/msmtprc <<HEREDOC
# Configuração de produção
defaults
auth ${SMTP_AUTH:-on}
tls ${SMTP_TLS:-on}
syslog on
account default
host ${SMTP_HOST}
port ${SMTP_PORT}
from ${SMTP_FROM:-${WORDPRESS_ADMIN_EMAIL}}
HEREDOC
if test -n "${SMTP_AUTH}"; then
echo "user ${SMTP_AUTH}" >> /etc/msmtprc;
fi
if test -n "${SMTP_USER}"; then
echo "user ${SMTP_USER}" >> /etc/msmtprc;
fi
if test -n "${SMTP_PASSWORD}"; then
echo password ${SMTP_PASSWORD} >> /etc/msmtprc;
fi
cat > /usr/local/etc/php/conf.d/99-mail.ini <<HEREDOC
sendmail_path = "/usr/bin/msmtp -t"
mail.add_x_header = On
HEREDOC
echo "smtp is set to ${SMTP_HOST}.";
echo "=== DEBUG ===";
echo;
echo /etc/msmtprc
cat /etc/msmtprc;
echo;
echo /usr/local/etc/php/conf.d/99-mail.ini;
cat /usr/local/etc/php/conf.d/99-mail.ini;
echo;
echo "=== DEBUG ==="
exit 0;
fi
echo "using default php mail solution";