[TUTORIAL] Spam reports per domain or per user

Dec 23, 2021
4
3
8
46
If most of the users do not want to receive a spam report, but some users or some domains wish to have it sent, I have used a following cronjob to have reports sent to specific users:

/etc/cron.daily/custom-spam-report

Bash:
#!/bin/sh

/usr/bin/pmgqm status -timespan week | awk 'NR>1 {print $3}'|grep -E 'user@domain1.com|domain2.com'|xargs -rn1 /usr/bin/pmgqm send -timespan week -receiver

Make the file executable:
Bash:
chmod +x /etc/cron.daily/custom-spam-report

Explanation:
  1. pmgqm status prints a list of recipients who have spam in quarantine, the first line is a header and the recipient is in 3rd column
  2. awk filters out the header line and picks out only recipients
  3. grep filters only those users or domains who wish to receive a report
  4. xargs runs the report sending pmgqm send one recipient at a time (-n1) and only if there is at least one recipient (-r)
I have chosen timespans so that the user gets the report daily, but it includes the quarantine messages for a whole week. We keep email in spam quarantine for two weeks in case someone wants to release a message even after it is not listed in a spam report.

It would be nice to have this feature in the GUI, to have an option to send spam report for some recipients even if it is by default switched off.
 
  • Like
Reactions: fgams
It would be nice to have this feature in the GUI, to have an option to send spam report for some recipients even if it is by default switched off.
My suggestion: just enable the spam quarantine for some users and for the rest, just mark the spam emails and deliver these emails to the users mailbox directly.
 

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!