Set Up Proxmox Alerts via Gmail
-
SSH into the Proxmox node and become the root user. Run the following commands to download the extra software dependencies we'll need:
apt updateapt install -y libsasl2-modules mailutils -
Enable 2FA for the Gmail account that will be used, by going to security settings.
-
Create an app password for the account.
- Go to App Passwords.
- Select app:
Mail. - Select device:
Other. - Type in:
Proxmoxor whatever you want here. - Save the displayed password to use in the Postfix credentials.
-
Write the Gmail credentials to a file and hash it. Again, make sure you are root.
echo "smtp.gmail.com youremail@gmail.com:yourpasswordFROMAppPasswords" > /etc/postfix/sasl_passwd# chmod u=rwchmod 600 /etc/postfix/sasl_passwd# generate /etc/postfix/sasl_passwd.dbpostmap hash:/etc/postfix/sasl_passwd -
Open the Postfix configuration file with the editor of your choice.
nano /etc/postfix/main.cf -
Append the following to the end of the file:
relayhost = smtp.gmail.com:587smtp_use_tls = yessmtp_sasl_auth_enable = yessmtp_sasl_security_options =smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdsmtp_tls_CAfile = /etc/ssl/certs/Entrust_Root_Certification_Authority.pemsmtp_tls_session_cache_database = btree:/var/lib/postfix/smtp_tls_session_cachesmtp_tls_session_cache_timeout = 3600sIMPORTANT: Comment out the existing line containing just
relayhost=since we are using this key in our configuration we just pasted in.
-
Reload Postfix:
postfix reload -
Test to make sure everything is working:
echo "sample message" | mail -s "sample subject" anotheremail@gmail.com