Skip to content

📣 Setting Up Email Alerts on Proxmox (Using Gmail & Postfix)

This guide shows how to configure Proxmox to send system notifications via email using Gmail’s SMTP servers. It's useful for receiving alerts about VM states, backups, or hardware failures.


1. Install Required Packages

First, install mailutils (for sending mail) and libsasl2-modules (to support SMTP authentication):

apt update
apt install -y libsasl2-modules mailutils

2. Generate an App Password from Google

If using Gmail, you must create an App Password (standard Google password won't work for SMTP). Go to:

👉 https://myaccount.google.com/apppasswords

Select “Mail” as the app, and generate a new password. Copy this for later.


3. Configure SMTP Credentials for Postfix

Create a file with your Gmail SMTP credentials:

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

Replace [email protected] and YourAppPassword accordingly.


4. Set Secure Permissions

Restrict file permissions to protect sensitive credentials:

chmod 600 /etc/postfix/sasl_passwd

5. Generate the Hashed Credentials File

Postfix uses a hashed version of the credentials file:

postmap hash:/etc/postfix/sasl_passwd

Confirm the .db file was created:

ls /etc/postfix/sasl_passwd.db

6. Edit Postfix Configuration

Open the Postfix config file:

nano /etc/postfix/main.cf

And append or update the following Gmail-specific settings:

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

These settings configure Postfix to authenticate via TLS with Gmail’s SMTP server.


7. Reload Postfix

Apply the changes:

postfix reload

8. Send a Test Email

You can verify the setup with a test message:

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

9. Customize the "From" Header

By default, Gmail may replace the sender with your Gmail address. To make the "From" field show a custom name like pve1-alert, do the following:

Install the PCRE module:

apt update
apt install postfix-pcre

Create a header rewrite rule:

nano /etc/postfix/smtp_header_checks

Add:

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

Then hash the file:

postmap hash:/etc/postfix/smtp_header_checks

Confirm it worked:

ls /etc/postfix/smtp_header_checks.db

10. Enable the Header Rewrite Rule

Edit your Postfix config again:

nano /etc/postfix/main.cf

At the bottom, add:

smtp_header_checks = pcre:/etc/postfix/smtp_header_checks

Reload the Postfix service:

postfix reload

Acknowledgment This guide is based on the original post by Techno Tim: Proxmox Alerts Guide. I’ve expanded on the steps with added explanations and commentary.