How to setup email notification on proxmox

By | July 16, 2022

I do run a lot of backup operation on proxmox and wanted to receive email with backup job details. Here is the step by step guide to achieve this goal.

Step 1: Install authentication library

apt-get install libsasl2-modules

Step 2: Create a password file

nano /etc/postfix/sasl_passwd

e.g >> smtp.gmail.com youremail@mail.com:your_password

Step 3: Create a database for the password file

postmap hash:/etc/postfix/sasl_passwd

Step 4: Protect the text of that password file

chmod 600 /etc/postfix/sasl_passwd

Step 5: Now we shall edit postfix configuration file. But before we do, lets take a backup

cp /etc/postfix/main.cf /etc/postfix/main.cf.backup

After backup, lets edit postfix configuration file

nano /etc/postfix/main.cf

Step 6: Add the mail details as follows

relayhost = smtp-host.domain.com:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_CApath = /etc/ssl/certs
smtp_sasl_security_options = noanonymous, noplaintext
smtp_sasl_tls_security_options = noanonymous 
relayhost = smtp-host.domain.com:587SMTP relay server name and port
smtp_use_tls = yesUse Transport Layer Security (TLS) encryption
smtp_sasl_auth_enable = yesEnable SASL client-side authentication using username and password
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwdLookup table containing username and password for authentication
smtp_tls_CApath = /etc/ssl/certsDirectory containing Certificate Authority certificates that Postfix will use to verify remote SMTP server’s certificates
smtp_sasl_security_options = noanonymous, noplaintextDon’t allow anonymous authentication or plaintext passwords for SASL authentication
smtp_sasl_tls_security_options = noanonymousDon’t allow anonymous TLS authentication
Explanation of the configuration

Step 7: Now reload and test

postfix reload

Send test email
echo "this is a test email" | mail -s "test email" alerts@domain.com -a "FROM:alerts@domain.com"