First of all, install postfix and remove sendmail: <br>
{{Code|yum -y install postfix<br> yum -y remove sendmail<br>}}
Openssl and openssl-perl are needed to generate certificates and create SSL connections to GMail<br>
Openssl should be installed already, but to be sure: <br>
{{Code|yum -y install openssl openssl-perl<br>}}
A Certificate Authority is needed to create the necessary certificates. You can skip the next paragraph if you already have one:<br>
{{Code|cd /etc/pki/tls/misc<br> ./CA.pl –newca<br>}}
*You will be prompted for the file name, hit enter to create a new CA.
Now a key that is sent to GMail to start the SSL encryption will be created: <br>
{{Code|cd /etc/pki/tls<br> mkdir gmail_relay<br> cd gmail_relay<br> openssl genrsa -out server.key 1024<br> openssl req -new -key server.key -out server.csr<br>}
You will be prompted for country etc. like when creating the CA. Enter the same values. <br>
As Common Name, now enter the name of your server, FQDN or not, your choice. <br>
{{Code|openssl ca -out server.pem -infiles server.csr<br>}
You will need to enter your passphrase again at this point.<br>
When asked if you want to sign the key, answer yes, same when asked if to commit it.
Add the following to the bottom of the file /etc/postfix/main.cf.
You do not need to change anything else in it, as the last setting for any option is the one that is saved.
{{Text|Text=#### GMail SSL SMTP Relay relayhost <nowiki>= </nowiki> [smtp.gmail.com]:587
#auth
smtp_sasl_auth_enable<nowiki>=</nowiki>yes smtp_sasl_password_maps <nowiki>= </nowiki> hash:/etc/postfix/sasl_passwd
#tls
smtp_use_tls <nowiki>= </nowiki> yes smtp_sasl_security_options <nowiki>= </nowiki> noanonymous smtp_sasl_tls_security_options <nowiki>= </nowiki> noanonymous smtp_tls_note_starttls_offer <nowiki>= </nowiki> yes tls_random_source <nowiki>= </nowiki> dev:/dev/urandom smtp_tls_scert_verifydepth <nowiki>= </nowiki> 5 smtp_tls_key_file<nowiki>=</nowiki>/etc/pki/tls/gmail_relay/server.key smtp_tls_cert_file<nowiki>=</nowiki>/etc/pki/tls/gmail_relay/server.pem smtpd_tls_ask_ccert <nowiki>= </nowiki> yes smtpd_tls_req_ccert <nowiki>=</nowiki>no smtp_tls_enforce_peername <nowiki>= no<br/nowiki>no}}
Create /etc/postfix/sasl_passwd file with your GMail login credentials that looks like below:
{{Text|Text=gmail-smtp.l.google.com user@gmail.com:password<br> smtp.gmail.com user@gmail.com:password<br>}}
Obviously, you need to change ''user'' to your username and ''password'' to your gmail password. <br>
Create the password database: <br>
{{Code|postmap hash:/etc/postfix/sasl_passwd}}
Protect the files with your GMail login data:
{{Code|chmod 600 /etc/postfix/sasl_passwd chmod 600 /etc/postfix/sasl_passwd.db chown postfix /etc/postfix/sasl_passwd chown postfix /etc/postfix/sasl_passwd.db<br>}}
Restart Postfix
{{Code|/etc/init.d/postfix restart}}
Now try sending a mail, it should reach your gmail account.