Setting up alerts in Proxmox is critical to making sure you are notified if something goes wrong with your servers. It’s so easy, I should have done this years ago! In this tutorial, we’ll set up email notifications using SMTP with Gmail or G Suite that send email alerts when there are disk errors, ZSF Issues, or when backup jobs run. We’ll then test the alerts to make sure they are working by yoinking a drive from my ZFS pool (and hopefully it doesn’t fail).
install dependencies –
apt update
apt install -y libsasl2-modules mailutils
ShellSessionConfigure app passwords on your Google account
https://myaccount.google.com/apppasswords
Configure postfix
echo "smtp.gmail.com [email protected]:YourAppPassword" > /etc/postfix/sasl_passwd
ShellSessionupdate permissions
chmod 600 /etc/postfix/sasl_passwd
ShellSessionhash the file
postmap hash:/etc/postfix/sasl_passwd
ShellSessioncheck to be sure the db file was created
cat /etc/postfix/sasl_passwd.db
ShellSessionedit postfix config
nano /etc/postfix/main.cf
ShellSession# google mail configuration
relayhost = smtp.gmail.com:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_security_options =
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CAfile = /etc/ssl/certs/Entrust_Root_Certification_Authority.pem
smtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cache
smtp_tls_session_cache_timeout = 3600s
ShellSessionreload postfix
postfix reload
ShellSessionsend a test email
echo "This is a test message sent from postfix on my Proxmox Server" | mail -s "Test Email from Proxmox" [email protected]
ShellSessionedit name in email
install dependency
apt update
apt install postfix-pcre
ShellSessionedit config
nano /etc/postfix/smtp_header_checks
ShellSessionadd the following text
/^From:.*/ REPLACE From: pve1-alert <[email protected]>
ShellSessionhash the file
postmap hash:/etc/postfix/smtp_header_checks
ShellSessioncheck the contents of the file
cat /etc/postfix/smtp_header_checks.db
ShellSessionadd the module to our postfix config
nano /etc/postfix/main.cf
ShellSessionadd the following to the end of the file
smtp_header_checks = pcre:/etc/postfix/smtp_header_checks
ShellSessionreload postfix service
postfix reload
ShellSession