Gmail smtp relay with postfix

Step:- 01
#sudo apt-get update && sudo apt-get upgrade
#sudo apt-get install libsasl2-modules postfix
#vi /etc/posttfix/main.cf

myhostname = mail.drbdtest.com


Step:-02

Generate app password for postfix


Step:-03

Add Gmail username and password to postfix

vi /etc/postfix/sasl/sasl_passwd
[smtp.gmail.com]:587 username@gmail.com:password

#sudo postmap /etc/postfix/sasl/sasl_passwd

sudo chown root:root /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db
sudo chmod 0600 /etc/postfix/sasl/sasl_passwd /etc/postfix/sasl/sasl_passwd.db

Configure postfix relay server
#vi /etc/opstfix/main.cf

relayhost = [smtp.gmail.com]:587
# 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


#sudo systemctl restart postfix


Step:-04

Test postfix


Ref:
https://www.linode.com/docs/email/postfix/configure-postfix-to-send-mail-using-gmail-and-google-apps-on-debian-or-ubuntu/
https://www.golinuxcloud.com/gmail-smtp-relay-server-postfix/


Comments

Popular posts from this blog

Cambium cnPilot E400/E410/E500 Configuration Tutorial

Disabling Zimbra's AntiSpam, Amavis and AntiVirus filtering

Error "Unable to retrive Zimbra GPG key for package validation"