Postfix- Relay Emails to Gmail

I prefer to use corporate mail server for mail relay mails from Linux box.

While settingup Nagios for my friend and as he insisted using Gmail to send Nagios alters I found interesting post.

Install dependencies.

yum -y install openssl-perl

If /etc/pki/CA/private/cakey.pem does not exists

/etc/pki/tls/misc/CA.pl -newca

That will create the cakey.pem file in /etc/pki/CA/private

Then edit the file /etc/pki/tls/openssl.cnf and set

dir = /etc/pki/CA

Generate CSR (in /etc/postfix/certs)

openssl genrsa -out itchy.key 1024
openssl req -new -key itchy.key -out itchy.csr
openssl ca -out itchy.pem -infiles itchy.csr

Postfix Configuration

relayhost = [smtp.gmail.com]:587

#auth
smtp_sasl_auth_enable=yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd

#tls
smtp_use_tls = yes
smtp_sasl_security_options = noanonymous
smtp_sasl_tls_security_options = noanonymous
smtp_tls_note_starttls_offer = yes
tls_random_source = dev:/dev/urandom
smtp_tls_scert_verifydepth = 5
smtp_tls_key_file=/etc/postfix/certs/itchy.key
smtp_tls_cert_file=/etc/postfix/certs/itchy.pem
smtpd_tls_ask_ccert = yes
smtpd_tls_req_ccert =no
smtp_tls_enforce_peername = no

cat /etc/postfix/sasl_passwd

gmail-smtp.l.google.com user@gmail.com:password
smtp.gmail.com user@gmail.com:password

postmap /etc/postfix/sasl_passwd

/etc/init.d/postfix reload

Source


if you find any missing point in here, please let us know in comment section or tweet us at @linuxreaders. To get more articles like this, subscribe to our RSS feeds / Mails.

Article by Dhaval Thakar

Hi, I am Linux Admin. You'll find my articles small & without much descriptions.
Read 218 articles by

Archives

Categories

Page optimized by WP Minify WordPress Plugin