Allow to use a SMTP server without authentication
This commit is contained in:
committed by
Juan Luis Baptiste
parent
2264af0bca
commit
b1ef5ea1d0
13
run.sh
13
run.sh
@@ -17,9 +17,8 @@ function add_config_value() {
|
||||
if [ -n "${SMTP_PASSWORD_FILE}" ]; then [ -f "${SMTP_PASSWORD_FILE}" ] && read SMTP_PASSWORD < ${SMTP_PASSWORD_FILE} || echo "SMTP_PASSWORD_FILE defined, but file not existing, skipping."; fi
|
||||
|
||||
[ -z "${SMTP_SERVER}" ] && echo "SMTP_SERVER is not set" && exit 1
|
||||
[ -z "${SMTP_USERNAME}" ] && echo "SMTP_USERNAME is not set" && exit 1
|
||||
[ -z "${SMTP_PASSWORD}" ] && echo "SMTP_PASSWORD is not set" && exit 1
|
||||
[ -z "${SERVER_HOSTNAME}" ] && echo "SERVER_HOSTNAME is not set" && exit 1
|
||||
[ ! -z "${SMTP_USERNAME}" -a -z "${SMTP_PASSWORD}" ] && echo "SMTP_USERNAME is set but SMTP_PASSWORD is not set" && exit 1
|
||||
|
||||
SMTP_PORT="${SMTP_PORT:-587}"
|
||||
|
||||
@@ -33,9 +32,11 @@ add_config_value "mydestination" 'localhost'
|
||||
add_config_value "myorigin" '$mydomain'
|
||||
add_config_value "relayhost" "[${SMTP_SERVER}]:${SMTP_PORT}"
|
||||
add_config_value "smtp_use_tls" "yes"
|
||||
add_config_value "smtp_sasl_auth_enable" "yes"
|
||||
add_config_value "smtp_sasl_password_maps" "lmdb:/etc/postfix/sasl_passwd"
|
||||
add_config_value "smtp_sasl_security_options" "noanonymous"
|
||||
if [ ! -z "${SMTP_USERNAME}" ]; then
|
||||
add_config_value "smtp_sasl_auth_enable" "yes"
|
||||
add_config_value "smtp_sasl_password_maps" "lmdb:/etc/postfix/sasl_passwd"
|
||||
add_config_value "smtp_sasl_security_options" "noanonymous"
|
||||
fi
|
||||
add_config_value "always_add_missing_headers" "${ALWAYS_ADD_MISSING_HEADERS:-no}"
|
||||
#Also use "native" option to allow looking up hosts added to /etc/hosts via
|
||||
# docker options (issue #51)
|
||||
@@ -47,7 +48,7 @@ if [ "${SMTP_PORT}" = "465" ]; then
|
||||
fi
|
||||
|
||||
# Create sasl_passwd file with auth credentials
|
||||
if [ ! -f /etc/postfix/sasl_passwd ]; then
|
||||
if [ ! -f /etc/postfix/sasl_passwd -a ! -z "${SMTP_USERNAME}" ]; then
|
||||
grep -q "${SMTP_SERVER}" /etc/postfix/sasl_passwd > /dev/null 2>&1
|
||||
if [ $? -gt 0 ]; then
|
||||
echo "Adding SASL authentication configuration"
|
||||
|
||||
Reference in New Issue
Block a user