Setting up GMail as a relay in Postfix always seems to be an issue with me. Here’s a quick overview of the process:
- Install Postfix (if not already installed)
- Configure Postfix (if no main.cf exists). Use:
sudo dpkg-reconfigure postfix
- Generate CSR, in /etc/postfix/certs
/usr/lib/ssl/misc/CA.pl -newca openssl genrsa -out itchy.key 1024 openssl req -new -key itchy.key -out itchy.csr openssl ca -out itchy.pem -infiles itchy.csr
- Edit main.cf
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
- Create /etc/postfix/sasl_passwd file
gmail-smtp.l.google.com user@gmail.com:password smtp.gmail.com user@gmail.com:password
- Generate map
postmap /etc/postfix/sasl_passwd
- Restart
/etc/init.d/postfix reload
Resources:
