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 mailutilsShellSessionConfigure app passwords on your Google account
https://myaccount.google.com/apppasswords
Configure postfix
echo "smtp.gmail.com [email protected]:YourAppPassword" > /etc/postfix/sasl_passwdShellSessionupdate permissions
chmod 600 /etc/postfix/sasl_passwdShellSessionhash the file
postmap hash:/etc/postfix/sasl_passwdShellSessioncheck to be sure the db file was created
cat /etc/postfix/sasl_passwd.dbShellSessionedit postfix config
nano /etc/postfix/main.cfShellSession# 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 = 3600sShellSessionreload postfix
postfix reloadShellSessionsend 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-pcreShellSessionedit config
nano /etc/postfix/smtp_header_checksShellSessionadd the following text
/^From:.*/ REPLACE From: pve1-alert <[email protected]>ShellSessionhash the file
postmap hash:/etc/postfix/smtp_header_checksShellSessioncheck the contents of the file
cat /etc/postfix/smtp_header_checks.dbShellSessionadd the module to our postfix config
nano /etc/postfix/main.cfShellSessionadd the following to the end of the file
smtp_header_checks = pcre:/etc/postfix/smtp_header_checksShellSessionreload postfix service
postfix reloadShellSession