Skip to content

Instantly share code, notes, and snippets.

@davxiao
Created June 8, 2020 17:45
Show Gist options
  • Save davxiao/ecf545d57925a815b274a981b1775622 to your computer and use it in GitHub Desktop.
Save davxiao/ecf545d57925a815b274a981b1775622 to your computer and use it in GitHub Desktop.
Postfix config for Gmail relay. Only allowing relay request from local network.
# See /usr/share/postfix/main.cf.dist for a commented, more complete version
myhostname=pve.home
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
# appending .domain is the MUA's job.
append_dot_mydomain = no
# Uncomment the next line to generate "delayed mail" warnings
#delay_warning_time = 4h
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = $myhostname, localhost.$mydomain, localhost
relayhost = [smtp.gmail.com]:587
mynetworks = 127.0.0.0/8 192.168.0.0/16 172.26.0.1/16
inet_interfaces = all
recipient_delimiter = +
# see https://www.linode.com/docs/email/postfix/configure-postfix-to-send-mail-using-gmail-and-google-apps-on-debian-or-ubuntu/
# Enable SASL authentication
smtp_sasl_auth_enable = yes
# Disallow methods that allow anonymous authentication
smtp_sasl_security_options = noanonymous
# Location of sasl_passwd
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
# Enable STARTTLS encryption
smtp_tls_security_level = encrypt
# Location of CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
inet_protocols = ipv4
# Allow connections from trusted networks only.
smtpd_client_restrictions = permit_mynetworks, reject
smtpd_recipient_restrictions = permit_mynetworks, permit_sasl_authenticated, reject
smtpd_relay_restrictions = permit_mynetworks, reject
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment