Skip to content

Setup external SMTP for Provmox

Stolen from

Gmail as an example:

Edit /etc/postfix/main.cf to include/change these lines:

Text Only
relayhost = [smtp.gmail.com]:587
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


#mydestination = $myhostname, localhost.$mydomain, localhost

Make sure there are no dupes as the main.cf may have smtp_sasl_security_options = {} , and relayhost = {}. Just delete or comment those lines.

Create an /etc/postfix/sasl_passwd file with:

Text Only
[smtp.gmail.com]:587    [email protected]:PASSWD

run

Bash
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd

install for passwd support:

Bash
apt-get install libsasl2-modules
Bash
systemctl restart postfix.service

Test:

Bash
echo "Test mail from postfix" | mail -s "Test Postfix" [email protected]

Test from PVE:

Bash
echo "test" | /usr/bin/pvemailforward

Logs are placed

/var/log/mail.warn

/var/log/mail.info

Customize From: This is nice so it's not from "root"​

Create smtp_header_checks file, this changes all outgoing mail:

Text Only
/^From:.*/ REPLACE From: HOSTNAME-alert <[email protected]>

Add to main.cf:

Text Only
smtp_header_checks = pcre:/etc/postfix/smtp_header_checks

Don't forget to run postmap on the header file

  • note. For pcre support you'll need to install apt install postfix-pcre and restart postfix service