Setup external SMTP for Provmox
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
install for passwd support:
Test:
Bash
echo "Test mail from postfix" | mail -s "Test Postfix" [email protected]
Test from PVE:
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:
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