Last active
December 19, 2018 10:20
-
-
Save metajiji/a385d6e08b17b735b1dbeef0d59d6416 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
SMTP_HOST=smtp.domain.ltd | |
SMTP_USER=user | |
SMTP_PASSWORD=ToPs3cR3t | |
# Edit main.cf | |
postconf -e 'mydestination = $myhostname, localhost.$mydomain, localhost' | |
postconf -e 'smtp_generic_maps = hash:/etc/postfix/smtp_maps' | |
postconf -e "relayhost = $SMTP_HOST" | |
postconf -e 'smtp_sasl_password_maps = hash:/etc/postfix/_smtp_sasl_password_maps' | |
postconf -e 'smtp_sasl_auth_enable = yes' | |
postconf -e 'smtp_sasl_security_options = noanonymous' | |
postconf -e 'smtp_tls_security_level = encrypt' | |
postconf -e 'smtp_use_tls = yes' | |
postconf -e 'canonical_maps = regexp:/etc/postfix/_canonical_maps' | |
postconf -e 'canonical_classes = envelope_sender' | |
postconf -e 'inet_protocols = ipv4' | |
# Create smtp config | |
echo "root $SMTP_USER" > /etc/postfix/smtp_maps | |
## Use the empty regexp to map *any* address to the desired envelope sender. | |
echo "// $SMTP_USER" > /etc/postfix/_canonical_maps | |
echo "$SMTP_HOST ${SMTP_USER}:$SMTP_PASSWORD" > /etc/postfix/_smtp_sasl_password_maps | |
chown root:root /etc/postfix/smtp_sasl_password_maps /etc/postfix/smtp_maps /etc/postfix/_canonical_maps | |
chmod 400 /etc/postfix/smtp_sasl_password_maps /etc/postfix/smtp_maps /etc/postfix/_canonical_maps | |
# Create Berkeley db files | |
postmap /etc/postfix/_smtp_sasl_password_maps | |
postmap /etc/postfix/smtp_maps | |
postmap /etc/postfix/_canonical_maps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment