Postfix send through SMTP relay

    • Postfix send through SMTP relay

      This allows Postfix to send emails through a third party SMTP relay like Gmail. I know on Debian based system you need libsasl2-modules installed.

      First create a SASL credential file, /etc/postfix/sasl_passwd:

      Source Code

      1. [smtp.gmail.com]:587 $USER@gmail.com:$PASS


      Generate a map file:
      postmap /etc/postfix/sasl_passwd
      It'll generate a /etc/postfix/sasl_passwd.db file.


      Let's secure those two files:
      chmod 0600 /etc/postfix/sasl_passwd*


      Add following lines to your /etc/postfix/main.cf:

      Source Code: /etc/postfix/main.cf

      1. relayhost = [smtp.gmail.com]:587
      2. smtp_sasl_auth_enable = yes
      3. smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
      4. smtp_sasl_security_options = noanonymous
      5. #smtp_use_tls = yes
      6. smtp_tls_security_level = may
      7. header_size_limit = 4096000


      Restart Postfix.
      I like cars and taking pictures! 8)