>

GMail as smartrelay on Ubuntu

Setting up GMail as a relay in Postfix always seems to be an issue with me. Here’s a quick overview of the process:

  1. Install Postfix (if not already installed)
  2. Configure Postfix (if no main.cf exists). Use:
    sudo dpkg-reconfigure postfix
  3. 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
  4. 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
  5. Create /etc/postfix/sasl_passwd file
    gmail-smtp.l.google.com user@gmail.com:password
    smtp.gmail.com user@gmail.com:password
  6. Generate map
    postmap /etc/postfix/sasl_passwd
  7. Restart
    /etc/init.d/postfix reload

Resources:

  1. https://help.ubuntu.com/community/Postfix
  2. http://ubuntulinux.co.in/blog/ubuntu/set-up-postfix-for-relaying-emails-via-gmail-smtp-server/
  3. http://bookmarks.honewatson.com/2008/04/20/postfix-gmail-smtp-relay/
banner ad

Comments are closed.