Skip to main content

Setting up email sending

  1. open /etc/postfix/main.cf
  2. add the following rows (make sure none of the rows are duplicated)
    #mydestination = $myhostname, server.local, localhost.local, , localhost # you can comment this out
    relayhost = [smtp.mail.com]:465 # replace this domain with your mail server
    smtp_use_tls = yes
    smtp_sasl_auth_enable = yes
    smtp_sasl_security_options = noanonymous
    smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
    smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt
    smtp_tls_wrappermode = yes
    smtp_tls_security_level = encrypt
  3. create this file: /etc/postfix/sasl_passwd with the following content:
    [smtp.mail.com]:465    test@mail.com:PASSWD
  4. make it only readable by your user: chmod 600 /etc/postfix/sasl_passwd
  5. then: postmap /etc/postfix/sasl_passwd
  6. install for passwd support: apt install libsasl2-modules
  7. restart postfix: systemctl restart postfix.service
  8. you can test it multiple ways:
    echo "Test mail from postfix" | mail -s "Test Postfix" test@test.com
    OR
    echo "test" | /usr/bin/pvemailforward
  9. logs can be found here:
    • /var/log/mail.warn
    • /var/log/mail.info

Sources: