Proxmox alert configuration via gmail

A short list to configure Proxmox VE to send alert using Gmail account;

#--------- Proxmox email configuration -------------

# Install authentication libraries
apt-get install libsasl2-modules

Configure app passwords on your Google account

https://myaccount.google.com/apppasswords

# Configure postfix
echo "smtp.gmail.com <youremail>@gmail.com:<app-password>"> /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 create
cat /etc/postfix/sasl_passwd.db

# edit postfix config
nano /etc/postfix/main.cf

# 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

# reload postfix
postfix reload

# send a test emails
echo "This is a test message sent from postfix on my Proxmox Server" | mail -s "Test Email from Proxmox" <your-email>@gmail.com
date | mail -s “test” <your-email>@gmail.com

# Now, fix 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: pvetower-alert pvetower-alert@<your-email>.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 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 a test emails
date | mail -s “test” <your-email>@gmail.com

--done

References

# steps reference list;
https://docs.technotim.live/posts/proxmox-alerts/
https://forum.proxmox.com/threads/proxmox-setup-for-gmail.13405/
FavoriteLoadingAdd to favorites
Spread the love

Author: Shahzad Khan

Software developer / Architect