Skip to content

Instantly share code, notes, and snippets.

@jkuester
Created January 28, 2019 17:19
Show Gist options
  • Save jkuester/68f5c0cb2ef34cd4f773b9e0b776a9a9 to your computer and use it in GitHub Desktop.
Save jkuester/68f5c0cb2ef34cd4f773b9e0b776a9a9 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Configuration for the script
POSTFIX_CONFIG=/overrides/postfix.cf
POSTFIX_SASL=/etc/postfix/sasl_passwd
# Set a safe umask
umask 077
# Add the relay host params
cat >> $POSTFIX_CONFIG << EOF
smtp_tls_security_level = encrypt
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:$POSTFIX_SASL
smtp_sasl_security_options = noanonymous
EOF
# Remove old
rm -f $POSTFIX_SASL
# Create new
cat > $POSTFIX_SASL << EOF
$RELAYHOST $RELAY_LOGIN:$RELAY_PASSWORD
EOF
chmod 600 $POSTFIX_SASL
postmap $POSTFIX_SASL
# Reload Postfix
postfix reload
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment