Maybe this is useful for some Admin
Bash:
#!/bin/bash
# delete all spam with score > $SCORE from pmg
SCORE=20
LOG=/root/scripts/deletion_log.txt
echo "Running at "`date` >>$LOG
# get stuff for the deletion log
pmgsh get /quarantine/spam 2>&1 | grep -v '200 OK' | jq '.[] | select(.spamlevel > '$SCORE') | .subject,.spamlevel'>>$LOG
# list all spam entries, filter by score, extract ID
# this gives a string
IDS=$(pmgsh get /quarantine/spam 2>&1 | grep -v '200 OK' | jq -r '.[] | select(.spamlevel > '$SCORE') | .id')
if [ -z "$IDS" ]; then
echo "No quarantined mails with spam score > $SCORE." >>$LOG
exit 0
fi
# convert string to array
arr=($IDS)
# print array elements on one line with separator
VAR=$(printf '%s;' "${arr[@]}");
# delete stuff from pmg with last separator cut from id argument string
pmgsh create /quarantine/content --action delete --id ${VAR::-1} 2>&1 | grep -v '200 OK'