Tech blog

Tutorial for ProxMox E-Mail Alerts

09 Dec 2023

Tutorial for ProxMox E-Mail Alerts

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
ShellSession

Configure app passwords on your Google account

https://myaccount.google.com/apppasswords

Configure postfix

echo "smtp.gmail.com [email protected]:YourAppPassword" > /etc/postfix/sasl_passwd
ShellSession

update permissions

chmod 600 /etc/postfix/sasl_passwd
ShellSession

hash the file

postmap hash:/etc/postfix/sasl_passwd
ShellSession

check to be sure the db file was created

cat /etc/postfix/sasl_passwd.db
ShellSession

edit 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
ShellSession

reload postfix

postfix reload
ShellSession

send a test email

echo "This is a test message sent from postfix on my Proxmox Server" | mail -s "Test Email from Proxmox" [email protected]
ShellSession

edit name in email

install dependency

apt update
apt install postfix-pcre
ShellSession

edit config

nano /etc/postfix/smtp_header_checks
ShellSession

add the following text

/^From:.*/ REPLACE From: pve1-alert <[email protected]>
ShellSession

hash the file

postmap hash:/etc/postfix/smtp_header_checks
ShellSession

check the contents of the file

cat /etc/postfix/smtp_header_checks.db
ShellSession

add the module to our postfix config

nano /etc/postfix/main.cf
ShellSession

add the following to the end of the file

smtp_header_checks = pcre:/etc/postfix/smtp_header_checks
ShellSession

reload postfix service

postfix reload
ShellSession

Rate this post

Comments

0 total