Proxmox Alerts Setup

Proxmox host setup

Table of contents

  1. Introduction
  2. Install dependencies
    1. Mailutils and SASL authentication libraries
    2. Configure app passwords on your Google account
  3. Configure postfix with new gmail and password
    1. Check the gmail email connection
  4. Fix the “from” name in email
    1. Add module to postfix and test

Introduction

This guide is adapted from Techno Tim’s Set up alerts in Proxmox before it’s too late! article and video.

Install dependencies

Do

Mailutils and SASL authentication libraries

apt update
apt install -y libsasl2-modules mailutils

Configure app passwords on your Google account

Configure app passwords on your Google account

Configure postfix with new gmail and password

Add your gmail and app password to postfix:

echo "smtp.gmail.com your-email@gmail.com:YourAppPassword" > /etc/postfix/sasl_passwd

Update permissions:

chmod 600 /etc/postfix/sasl_passwd

Hash the file:

postmap hash:/etc/postfix/sasl_passwd

Check to to be sure the db file was created:

cat /etc/postfix/sasl_passwd.db

Edit postfix config:

nano /etc/postfix/main.cf

Comment out line 26:

### relayhost =

Add this text at end of file:

# 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

Save the file.

Check the gmail email connection

Reload postfix

postfix reload

Send a test email

echo "This is a test message sent from postfix on my Proxmox Server" | mail -s "Test Email from Proxmox" shulerpve1@gmail.com

Fix the “from” name in email

Install dependency:

apt update
apt install postfix-pcre

Edit config:

nano /etc/postfix/smtp_header_checks

Add the following text:

/^From:.*/ REPLACE From: pve1-alert <pve1-alert@gmail.com>

Hash the file:

postmap hash:/etc/postfix/smtp_header_checks

Check the contents of the file:

cat /etc/postfix/smtp_header_checks.db

Add module to postfix and test

Add the module to our postfix config:

nano /etc/postfix/main.cf

Add to the end of the file:

smtp_header_checks = pcre:/etc/postfix/smtp_header_checks

Reload postfix service:

postfix reload

Send another test email:

echo "This is a second test message sent from postfix on my Proxmox Server" | mail -s "Second Test Email from Proxmox" shulerpve1@gmail.com