[TUTORIAL] Spam reports per domain or per user

Dec 23, 2021
5
5
8
47
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: TechTrend and 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.