I'm not sure I did this in the proxmox way but I couldn't get email to relay to me and some posts were dated or didn't work for me, so I did the following:
Gmail for example:
Change /etc/postfix/main.cf to include/change these lines:
Be 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:
run
install for passwd support:
Restart service:
Test:
Test from PVE:
is helpful as well as
Create smtp_header_checks file, this changes all outgoing mail:
Add to main.cf:
Don't forget to run postmap on the header file
#note. For pcre support you'll need to install
Gmail for example:
Change /etc/postfix/main.cf to include/change these lines:
Code:
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
Be 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:
Code:
[smtp.gmail.com]:587 testmehere@gmail.com:PASSWD
run
Code:
chmod 600 /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
install for passwd support:
Code:
apt-get install libsasl2-modules
Restart service:
Code:
systemctl restart postfix.service
Test:
Code:
echo "Test mail from postfix" | mail -s "Test Postfix" test@test.com
Test from PVE:
Code:
echo "test" | /usr/bin/pvemailforward
Logs:
Code:
/var/log/mail.warn
Code:
/var/log/mail.info
Customize From:
This is nice so it's not from "root"
This is nice so it's not from "root"
Create smtp_header_checks file, this changes all outgoing mail:
Code:
/^From:.*/ REPLACE From: HOSTNAME-alert <HOSTNAME-alert@something.com>
Add to main.cf:
Code:
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
Last edited: