Skip to main content

Setting up email sending

    create a backup of your postfix config: cp /etc/postfix/main.cf /etc/postfix/main_bak.cf open /etc/postfix/main.cf 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
    create this file: /etc/postfix/sasl_passwd with the following content:
    [smtp.mail.com]:465    test@mail.com:PASSWD
    make it only readable by your user: chmod 600 /etc/postfix/sasl_passwd then: postmap /etc/postfix/sasl_passwd install for passwd support: apt install libsasl2-modules restart postfix: systemctl restart postfix.service you can test it multiple ways:
    echo "Test mail from postfix" | mail -s "Test Postfix" test@test.com
    OR
    echo "test" | /usr/bin/pvemailforward
    logs can be found here:
    • /var/log/mail.warn
    • /var/log/mail.info

    Sources: