Roundcube/Plugin/markasjunk
Mark-as-junk
Adds the sender's email address to the blacklist, or run a command such as sa_learn.
- Shipped with
Roundcube
- Plugin name: markasjunk
- README (detailed drivers howto)
With this nice plugin the end user can add the sender's email address to the blacklist, or run a command such as
sa_learn
.Create the config file from the template cp config.inc.php.dist config.inc.php
sa_blacklist
driver
- Requires
spamassassin-user-prefs
(sauserprefs
) plugin andSpamassassin Userprefs
Clicking on the button "Mark as Junk" creates a new "Black_list from" record in the database and moves the message in the Junk folder eventually marking it as read. Clicking on the button "Mark as Ham" creates a record "White_list from" in the database and restores the message in the Inbox.
To use the plugin with the driver
sa_blacklist
: $config['markasjunk_learning_driver'] = 'sa_blacklist';The following
cmd_learn
driver should not be used anymore, as we already setup a cronjob for training our bayesian filter and reporting our spam (more info here).
cmd_learn
driver
- Thanks to Gabriel Torres for the hints concerning this setup
This driver calls an external command to process the message. You can use it to call
sa_learn
andspamassassin
in cascade. Be aware that you have to eventually removeshell_exec
fromdisable_functions
in yourphp.ini
so thatphp
can execute shell commands.Prepare the shell script with the commands to run when clicking on the "Mark as junk" button. Save as
/usr/local/bin/teach_spam.sh
the following code cat > /usr/local/bin/teach_spam.sh << __EOF__ #!/bin/bash /usr/local/bin/sa-learn --spam --username=$1 $2 >> /var/log/spamassassin/sa_learn.log 2>&1 /usr/local/bin/spamassassin --nocreate-prefs --report < $2 >> /var/log/spamassassin/spamassassin.log 2>&1 __EOF__ The first command feeds the mail toSpamAssassin
, allowing it to 'learn' what signs are likely to mean spam. The latter one reports the mail as spam toRazor
,Pyzor
andSpamcop
.Now prepare the shell script with the commands to run when clicking on the "Mark as ham" button. Save as
/usr/local/bin/revoke_spam.sh
the following code cat > /usr/local/bin/revoke_spam.sh << __EOF__ #!/bin/bash /usr/local/bin/sa-learn --ham --username=$1 $2 >> /var/log/spamassassin/sa_learn.log 2>&1 /usr/local/bin/spamassassin --nocreate-prefs --revoke < $2 >> /var/log/spamassassin/spamassassin.log 2>&1 __EOF__ Again, the first command feeds the mail toSpamAssassin
, allowing it to 'learn' which signs are likely to mean ham. The latter one revoke the report toRazor
. Apparently the revocation is not possible withPyzor
andSpamcop
(but I didn't look deeply in my log yet).Provide execute priviledges to the newly created scripts chmod +x /usr/local/bin/teach_spam.sh /usr/local/bin/revoke_spam.sh Set these options $config['markasjunk_learning_driver'] = 'cmd_learn'; $config['markasjunk_spam_cmd'] = '/usr/local/bin/teach_spam.sh %u %f'; $config['markasjunk_ham_cmd'] = '/usr/local/bin/revoke_spam.sh %u %f'; 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__ You have to assign
+w
priviledges toapache
in the log dir and toRazor
's identity-* files, asRoundcube
is runned by apache: chgrp apache /var/log/spamassassin chmod g+w /var/log/spamassassin chgrp apache /etc/mail/spamassassin/.razor/identity-* chmod 640 /etc/mail/spamassassin/.razor/identity-* chmod 644 /etc/mail/spamassassin/.razor/razor-agent.log
multi_driver
driver
- Original driver for the ancient
markasjunk2
pluginmulti_driver
plugin patched formarkasjunk
(diff here)It is possible to run multiple drivers when marking a message as spam/ham. I patched the original version by Philip Weir to work with
markasjunk
and runsa_blacklist
followed bycmd_learn
.Install as follows: cd /var/www/roundcube/plugins/markasjunk/drivers wget https://notes.sagredo.eu/files/qmail/patches/roundcube/markasjunk-multi_driver/multi_driver.txt mv multi_driver.txt multi_driver.php Set the correct driver in the config file: $config['markasjunk_learning_driver'] = 'multi_driver'; Be aware that the
markasjunk
'smulti_driver
driver, when enabled, seems to prevent the display of the attached images. Why this driver is related to this problem is a mistery. Any comment on this will be welcome.