Configure Postfix to use Gmail as a Mail Relay

In this tutorial, I setup and Configure Postfix to use Gmail as a Mail Relay with 587 port.
  • OS: Centos
  • User: root
Install postfix
yum install postfix mailx cyrus-sasl cyrus-sasl-plain
To configure postfix to use Gmail as a Mail Relay
vi /etc/postfix/main.cf
Add or modify the following as below:
#To use smpt gmail with 587 port
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
smtp_tls_security_level = encrypt
# Location of CA certificates
smtp_tls_CAfile = /etc/ssl/certs/ca-bundle.crt
To configure Gmail authentication
vi /etc/postfix/sasl_passwd
Add the line as below:
[smtp.gmail.com]:587    [email protected]:password
Running commands as below:
chmod 600 /etc/postfix/sasl_passwd
chown root:root /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db
postmap /etc/postfix/sasl_passwd
To restart postfix service
service postfix start
Test send a email 
echo "Test Mail" | mailx -v -r "[email protected]" -s "Test Mail 01" [email protected]

Troubleshooting - Enable "Less secure apps" access

The solve problem to link: https://support.google.com/accounts/answer/6010255?hl=en

Comments

  1. Ummid hai ki aapko ye article bahut pasand aayega aur agar kuch galat lage toh comment karke jaroor bataye aur ye bhi bataye ki aapko ye post kaisi lagi. create gmail account



    ReplyDelete

Post a Comment

Popular posts from this blog

zimbra some services are not running [Solve problem]

Bash script list all IP addresses connected to Server

How to install php7 on centos 6