Backup notification

hidalgo

Renowned Member
Nov 11, 2016
62
0
71
58
Hi
Because of SPAM detection of the emails from my proxmox server, I chooose to use the Notifications method to send an email, if the backup is done. Unfortunately I can not choose to skip the email on success and only send one on failure. Maybe I have tho configure this in Notification Matchers but I don’t have any idea how to do it.
Thanks for helping
 
Would like to hook in here. We get emails with.
root@fullhostname (FQDN)
This does not match the email domain which is set in the SMTP settings.

This is with the Backup tool - so we now get;
Code:
vzdump backup tool <root@prox00.domainA.com>
Instead this should be changeable to like
Code:
Proxmox Backup {host} <setfromaddress@domeinB.com>

So we did specify the From Addresses in the SMTP connector but its not used.
 
You‘ll need additional modifications for SMTP ELHO etc.

I wrote a little script which I use on new installs:

Bash:
#!/bin/bash

set -e

echo "== Proxmox SMTP Notification Setup (Postfix) =="

# ─────────────────────────────────────────────
# 1. User Input
# ─────────────────────────────────────────────
read -rp "FQDN of this host (e.g. pve01.example.com): " FQDN
read -rp "Your domain name (e.g. example.com): " MAILDOMAIN
read -rp "SMTP relay server (e.g. smtp.example.com): " SMTPRELAY
read -rp "SMTP relay port (e.g. 587): " SMTPPORT
read -rp "SMTP username: " SMTPUSER
read -rsp "SMTP password: " SMTPPASS
echo
read -rp "Test recipient email (e.g. admin@example.com): " MAILTO

# ─────────────────────────────────────────────
# 2. Set system hostname
# ─────────────────────────────────────────────
echo "[+] Setting system hostname to $FQDN"
hostnamectl set-hostname "$FQDN"

# ─────────────────────────────────────────────
# 3. Install postfix and mail utilities
# ─────────────────────────────────────────────
echo "[+] Installing postfix and mailutils..."
apt update && DEBIAN_FRONTEND=noninteractive apt install -y postfix mailutils

# Set mailname (used as sender domain)
echo "$MAILDOMAIN" > /etc/mailname

# ─────────────────────────────────────────────
# 4. Configure Postfix for external relay
# ─────────────────────────────────────────────
echo "[+] Configuring postfix..."
postconf -e "myhostname = $FQDN"
postconf -e "myorigin = /etc/mailname"
postconf -e "relayhost = [$SMTPRELAY]:$SMTPPORT"
postconf -e "smtp_use_tls = yes"
postconf -e "smtp_sasl_auth_enable = yes"
postconf -e "smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd"
postconf -e "smtp_sasl_security_options = noanonymous"
postconf -e "smtp_tls_CAfile = /etc/ssl/certs/ca-certificates.crt"

# ─────────────────────────────────────────────
# 5. Add SMTP credentials
# ─────────────────────────────────────────────
echo "[+] Writing SMTP credentials..."
echo "[$SMTPRELAY]:$SMTPPORT $SMTPUSER:$SMTPPASS" > /etc/postfix/sasl_passwd
postmap /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd /etc/postfix/sasl_passwd.db

# ─────────────────────────────────────────────
# 6. Restart Postfix and send test mail
# ─────────────────────────────────────────────
echo "[+] Restarting postfix..."
systemctl restart postfix

echo "[+] Sending test email to $MAILTO..."
echo "This is a test email from Proxmox host: $FQDN" | mail -s "Proxmox SMTP Test [$FQDN]" "$MAILTO"

echo "[✓] Setup complete. Check your inbox!"

You‘ll need to make it executable with


Bash:
chmod +x yourscriptname.sh

and run it afterwards.
 
  • Like
Reactions: hidalgo
Awesome - the issue has been resolved like - we had the notification set to auto instead of Notification System
So it reverted to the default - which was Email Legacy