Getting email notifications when Proxmox when backups or drives fails is an important part of monitoring that status of your Proxmox setup and virtual machines. This Proxmox: Setup Email Service article will walk you through setting up an email notification service so that you can receive messages from your Proxmox setup when something goes wrong and then jump into action. ProxmoxÂ can let you know when backups succeed or fail or when you are having health issues with a ZFS drive. This article will use gmail as an example, but it you know the settings for
This is part of digiMootâ€™s series of articles on Proxmox installations, configurations and setup.
Okay, let’s get started with this Proxmox: Setup Email Service article. This article will be done mostly from the command prompt. You need to get to the Proxmox shell, either through the webUI or connect via SSH.
Once at the shell, we will need to install the prerequisites with the following commands:
apt install -y libsasl2-modules
Generate 2FA Password (Optional)
The account I use doesn’t have 2FA but yours might. If you do, you will first have to generate a password to your email specific to Proxmox. To do this, login to your email account and then access your account password page. Add a custom application (select other), name it, and then generate a password. Copy and paste this password somewhere for use below.
The next thing we need to do is to configure the Postfix service. We need to edit the Postfix config file, but first lets back it up with this command:
cp /etc/postfix/main.cf /etc/postfix/main_bak.cf
Once it’s backed up, let get in there and edit it. I use nano and so run the following command, but you can use an editor of your choice:
Â We will want to add the following, to the end of the file:
relayhost = [smtp.gmail.com]:587 smtp_use_tls = yes smtp_sasl_auth_enable = yes smtp_sasl_security_options = noanonymous smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt #mydestination = $myhostname, localhost.$mydomain, localhost
In this file we have to be careful not to duplicate any lines we are adding with those already in the file. Check each line that has been added and if that line exists already, you will need to comment out the line that was already in the file by adding a ‘#’ to that start of the line. You wll notice that, in the example image below, I had to comment out the
relayhost = line.
Once you’re done save the file and exit (in nano Ctrl-X and then ‘Y’).
You may have noticed that this file links to a sasl_passwd file. This file will store the email address and password for your email and this is what we will edit next:
In this file you will need to enter your credentials for you email, like the example below. Obviously you will need to replace ‘EMAILADDRESS’ with your email address and ‘PASSWORD’ with your password. Remember that if you used 2FA above, you will need to use the password generated in hat optional step.
Once you’ve put your credentials in this file, then we will need to set the securities properly to protect your password. Run the following command.
chmod 600 /etc/postfix/sasl_passwd
Now lets update the postmap table with this new information by running:
Now we can restart the postfix service:
systemctl restart postfix.service
Test Email Service
Now things should be ready to go, but lets give it a test. First lets send a test email with the mail service, using the following command (replacing the email address with the test recipient):
echo "Test mail from Proxmox" | mail -s "Test Proxmox" firstname.lastname@example.org
Check your email and you should see a message there if everything is working. If it is, we can also test if from PVE with the following:
echo "test" | /usr/bin/pvemailforward
Adding an Email to your Backup Tasks
Alright, now the important part is to make sure your email address is listed on your backup tasks. For this part you can leave the command prompt and head back to the Proxmox WebUI.
Click on DataCenter -> Backup and then select your backup task. Click edit and then in the top right of the window there will be a field which says ‘Send email to:”. You can enter the address of the email you wish to send to.
Alright! That’s it! You’ve completed this Proxmox: Setup Email Service article and now have notifications configured for your backup tasks!