Install postfix and required packages:
Create SSL cert:
Create GMail authentication file:
Add the follow content:
Generate postfix sasl_passwd database:
Setting Postfix
Edit main.cf
Write the following contents to main.cf
Finally, restart postfix
# yum install postfix cyrus-sasl cyrus-sasl-plain cyrus-sasl-md5 # chkconfig postfix on # chkconfig saslauthd on
Create SSL cert:
# mkdir /etc/postfix/certs # cd /etc/postfix/certs # openssl dsaparam 1024 -out dsa1024.pem # openssl req -x509 -nodes -days 3650 -newkey dsa:dsa1024.pem -out mycert.pem -
keyout mykey.pem # ln -s mycert.pem CAcert.pem # openssl req -x509 -new -days 3650 -key mykey.pem -out mycert.pem
Create GMail authentication file:
# vi /etc/postfix/sasl_passwd
Add the follow content:
smtp.gmail.com username@googleapp.domain:password
Generate postfix sasl_passwd database:
# postmap hash:/etc/postfix/sasl_passwd # chmod 600 /etc/postfix/sasl_passwd # chmod 600 /etc/postfix/sasl_passwd.db
Setting Postfix
# vi /etc/postfix/main.cf
Edit main.cf
inet_interfaces = all
mydestination = localhost, $myhostname, localhost.$mydomain
mynetworks = 172.30.10.0/24
Write the following contents to main.cf
# SMTP relayhost relayhost = [smtp.gmail.com]:587 ## TLS Settings smtp_tls_loglevel = 1 smtp_tls_CAfile = /etc/postfix/certs/CAcert.pem smtp_tls_cert_file = /etc/postfix/certs/mycert.pem smtp_tls_key_file = /etc/postfix/certs/mykey.pem smtp_use_tls = yes smtpd_tls_CAfile = /etc/postfix/certs/CAcert.pem smtpd_tls_cert_file = /etc/postfix/certs/mycert.pem smtpd_tls_key_file = /etc/postfix/certs/mykey.pem smtpd_tls_received_header = yes smtpd_use_tls = yes # configuracion tls smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_security_options = noanonymous smtp_sasl_tls_security_options = noanonymous # alias de mapeo interno a externo smtp_generic_maps = hash:/etc/postfix/generic
Finally, restart postfix
# postmap hash:/etc/postfix/generic # /etc/init.d/postfix restart
Credit to my senior Voo
Thanks manager Gab
ReplyDeleteThanks CTO Gab
ReplyDelete