Skip to main content

Setting up email sending

  1. create a backup of your postfix config: cp /etc/postfix/main.cf /etc/postfix/main_bak.cf
  2. open /etc/postfix/main.cf
  3. 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
    
    # If your mail provider doesn't support ipv6, add/change this line
    inet_protocols = ipv4
  4. create this file: /etc/postfix/sasl_passwd with the following content:
    [smtp.mail.com]:465    test@mail.com:PASSWD
  5. make it only readable by your user: chmod 600 /etc/postfix/sasl_passwd
  6. then: postmap /etc/postfix/sasl_passwd
  7. install for passwd support: apt install libsasl2-modules
  8. restart postfix: systemctl restart postfix.service
  9. you can test it multiple ways:
    echo "Test mail from postfix" | mail -s "Test Postfix" test@test.com
    OR
    echo "test" | /usr/bin/pvemailforward
  10. logs can be found here:
    • /var/log/mail.warn
    • /var/log/mail.info
Common Issue:

If you can't send emails, because the domain in the FROM address is pointing to your server and the configured mail server rejects the mails with the following error:

Sender address rejected: Domain not found (in reply to RCPT TO command))

Then go to Datacenter -> Options -> Email from address and change it from root@$hostname to something that your mail server will accept.

Sources: