feat: add option to read variables from file
All checks were successful
ci/woodpecker/push/build-dev Pipeline was successful
All checks were successful
ci/woodpecker/push/build-dev Pipeline was successful
This commit is contained in:
@@ -1,17 +1,48 @@
|
|||||||
#! /usr/bin/env sh
|
#! /usr/bin/env sh
|
||||||
|
|
||||||
|
if [ -n "${SMTP_HOST_FILE}" ]; then
|
||||||
|
SMTP_HOST=$cat ${SMTP_HOST_FILE});
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${SMTP_PORT_FILE}" ]; then
|
||||||
|
SMTP_PORT=$(cat ${SMTP_PORT_FILE});
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${SMTP_FROM_FILE}" ]; then
|
||||||
|
SMTP_FROM=$(cat ${SMTP_FROM_FILE});
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${SMTP_USER_FILE}" ]; then
|
||||||
|
SMTP_USER=$(cat ${SMTP_USER_FILE});
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${SMTP_PASSWORD_FILE}" ]; then
|
||||||
|
SMTP_PASSWORD=$(cat ${SMTP_PASSWORD_FILE});
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${EMAIL_FILE}" ]; then
|
||||||
|
EMAIL=$(cat ${EMAIL_FILE});
|
||||||
|
else
|
||||||
|
if [ -n "${EMAIL}" ]; then
|
||||||
|
EMAIL="To: ${TO_ADDRESS}\nSubject: ${SUBJECT}\n\n${MESSAGE}";
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "${MSMTP_CONFIG_FILE}" ]; then
|
||||||
|
MSMTP_CONFIG_FILE="~/.msmtprc"
|
||||||
|
touch ${MSMTP_CONFIG_FILE}
|
||||||
|
chmod 600 ${MSMTP_CONFIG_FILE}
|
||||||
echo "defaults
|
echo "defaults
|
||||||
auth on
|
auth ${SMTP_AUTH:-on}
|
||||||
tls on
|
tls ${SMTP_TLS:-on}
|
||||||
|
|
||||||
account default
|
account default
|
||||||
host ${SMTP_HOST}
|
host ${SMTP_HOST}
|
||||||
port ${SMTP_PORT}
|
port ${SMTP_PORT:-587}
|
||||||
tls_starttls ${SMTP_STARTTLS}
|
tls_starttls ${SMTP_STARTTLS:-on}
|
||||||
from ${SMTP_FROM}
|
from ${SMTP_FROM}
|
||||||
user ${SMTP_USER}
|
user ${SMTP_USER}
|
||||||
password ${SMTP_PASSWORD}" > ~/.msmtprc
|
password ${SMTP_PASSWORD}" > ${MSMTP_CONFIG_FILE}
|
||||||
|
fi
|
||||||
|
|
||||||
chmod 600 ~/.msmtprc
|
echo -e "${EMAIL}" | msmtp --read-recipients -C ${MSMTP_CONFIG_FILE}
|
||||||
|
|
||||||
echo -e "Subject: ${SUBJECT}\n\n${MESSAGE}" | msmtp ${TO_ADDRESS}
|
|
||||||
Reference in New Issue
Block a user