June 20, 2021 Roberto Puzzanghera 2 comments
Now that we have the spam filters in place we have to train our bayesian system and report our spam to Razor
, Pyzor
and Spamcop
.
The obvious thing that comes in mind at this point could be to call sa_learn
and spamassassin --report
in cascade when clicking in the Roundcube
webmail's "Mark as Junk" button (look at the cmd_learn
and multi_driver
drivers of the markasjunk plugin), but this option has a couple of downsides:
Therefore it is better to run these two tasks by means a cronjob every night (and this is going to solve the first issue), processing the messages stored in a folder where the users have copied only real spam or ham messages (then fixing the second as well).
When you configured dovecot
you have prepared the code for the autocreation of the TeachSpam and TeachNotSpam mailboxes as sons of Junk. If this is not a fresh installation or you configured dovecot
some time ago, check your 15-mailboxes.conf
file:
mailbox "Junk.TeachSpam" { auto = subscribe autoexpunge = 5d } mailbox "Junk.TeachNotSpam" { auto = subscribe autoexpunge = 30d }
Now download my shell script
cd /usr/local/bin wget https://notes.sagredo.eu/files/qmail/sa_cron.sh chmod +x sa_cron.sh
and setup a cronjob to run it every night, for example
45 2 * * * /usr/local/bin/sa_cron.sh >> /var/log/cron
If you run it with no arguments, the script will do the job for all users having the .Junk.TeachSpam and .Junk.TeachNotSpam mailboxes in their Maildirs.
If you want to test it for a single admin user you can run it in the following way:
sa_cron.sh username@domain.tld
Edit the script and set DELETE_TEACH_DATA=1
if you want to delete the messages after they have been processed. I commented out the line which deletes the messages in the TeachNotSpam mailbox because I'm not sure that deleting the ham messages is a good idea.
Set DEBUG=1
to run sa_learn
and spamassassin
in debug mode, so that the logs will show everything.
Setup che logrotate for the above log files:
cat > /etc/logrotate.d/spam_reports << __EOF__ /var/log/spamassassin/spamassassin.log /var/log/spamassassin/sa_learn.log { su root apache rotate 5 daily missingok notifempty delaycompress create 664 root apache sharedscripts } __EOF__
Failed after apply roberto-netqmail-1.06.patch-2022.02.13
May 23, 2022 19:45
Failed after apply roberto-netqmail-1.06.patch-2022.02.13
May 23, 2022 18:52
qmail-smtpd: read failed (hang up before quit cmd)
May 23, 2022 16:17
qmail-smtpd: read failed (hang up before quit cmd)
May 22, 2022 17:32
Failed after apply roberto-netqmail-1.06.patch-2022.02.13
May 19, 2022 21:33
Failed after apply roberto-netqmail-1.06.patch-2022.02.13
May 19, 2022 21:23
Failed after apply roberto-netqmail-1.06.patch-2022.02.13
May 17, 2022 20:32
Failed after apply roberto-netqmail-1.06.patch-2022.02.13
May 17, 2022 19:57
Failed after apply roberto-netqmail-1.06.patch-2022.02.13
May 13, 2022 16:35
Failed after apply roberto-netqmail-1.06.patch-2022.02.13
May 13, 2022 16:30
Tags
apache clamav dkim dovecot ezmlm fail2ban hacks lamp letsencrypt linux linux-vserver lxc mariadb mediawiki mozilla mysql openboard owncloud patches php proftpd qmail qmail-spp qmailadmin rbl roundcube rsync sieve simscan slackware solr spamassassin spf ssh ssl surbl tcprules tex ucspi-tcp vpopmail vqadmin
Comments
log file duplication?
Robert February 27, 2022 11:11
Hi,
In the installation step a log is setup for spamd and I don't know if the /var/log/spamassassin/spamassassin.log setup here has to be separate or if it can point to the other one?
Reply | Permalink
log file duplication?
Roberto Puzzanghera Robert February 27, 2022 11:16
it can be the same, but I prefer to separate the log of spamd from these one
Edit: eventually, you have to set the log file inside the script
Reply | Permalink