Installing Postfix is easy, just run this command as root:
yum install postfix mailx cyrus-sasl-plain
Configuring
Create a file named sasl_passwd in /etc/postfix. Replace smtp_user and smtp_passwd with their respective values.
echo "smtp.gmail.com user@gmail.com:Gmail_password" > /etc/postfix/sasl_passwd
You then hash that file so that the password is not stored in clear text. This command will create a file named sasl_passwd.db in the /etc/postfix/ directory.
postmap hash:/etc/postfix/sasl_passwd
After that is done, add these to the bottom of /etc/postfix/main.cf. This is assuming that your root certificates installed from openssl are located in /etc/pki/tls/certs/ca-bundle.crt.
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
# Secure channel TLS with exact nexthop name match.
smtp_tls_security_level = secure
smtp_tls_mandatory_protocols = TLSv1
smtp_tls_mandatory_ciphers = high
smtp_tls_secure_cert_match = nexthop
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
relayhost = smtp.gmail.com:587
After that is done, restart postfix:
service postfix restart
Now test it to make sure it is working. Run this in the terminal:
mail email@domain
Fill in the subject, put something in the body and then type a . on a blank line to end and hit enter.
If all went well, you should get an email at the email address you entered. If you do, you can delete the file that has the password.
rm /etc/postfix/sasl_passwd
If it did not work, check the log to see what happened.
tail /var/log/maillog