E-Mail Notificiation with sendmail and/or smtp Server

Pampa Party

Member
Apr 26, 2023
53
3
8
Hi,

i would like to know ho i can set an sendmail client to use my smtp client i set up ober the proxmox gui in a script like:

Code:
#!/bin/bash

# Protokolldatei mit Tageszeitstempel
LOGFILE="/var/log/clamav/clamav-$(date +'%Y-%m-%d').log"

# E-Mail-Konfigurationsdetails
EMAIL_MSG="Bitte beachten Sie die beigefügte Protokolldatei."
#EMAIL_FROM=
#EMAIL_TO=

# Gesamtes System scannen
DIRTOSCAN="/"

# Verzeichnisse ausschließen (Regex für --exclude-dir)
EXCLUDE_DIRS="^/proc|^/sys|^/dev|^/run|^/tmp"

# Scan starten
echo "Starte einen vollständigen Scan des Systems. Ergebnisse werden in $LOGFILE gespeichert."

# Führe clamscan aus und protokolliere
clamscan -ri "$DIRTOSCAN" --exclude-dir="$EXCLUDE_DIRS" >> "$LOGFILE"

# Überprüfe auf Malware
MALWARE=$(tail "$LOGFILE" | grep Infected | cut -d" " -f3)
if [ "$MALWARE" -ne "0" ]; thenecho "$EMAIL_MSG"|mail -a "$LOGFILE" -s "ClamAV: Malware Found" -r "$EMAIL_FROM" "$EMAIL_TO";
fi

exit 0

all i´ve tried failed so far. For freshclam i get a notification without setting anything. So i guess there must be an easy way to set this as well for clamscan, maybe without a script. So if anybody know how to automate clamscan with getting an e-mail with the results would be lovely.
 
Last edited:

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!