Roundcube/Plugin/markasjunk: Unterschied zwischen den Versionen
Keine Bearbeitungszusammenfassung |
Keine Bearbeitungszusammenfassung |
||
| (2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt) | |||
| Zeile 1: | Zeile 1: | ||
== Mark-as-junk == | == Mark-as-junk == | ||
Adds the sender's email address to the blacklist, or run a command such as sa_learn. | |||
* Shipped with <code>Roundcube</code> | * Shipped with <code>Roundcube</code> | ||
| Zeile 85: | Zeile 85: | ||
# https://www.allerstorfer.at/roundcube-nachricht-als-spam-markieren/ | # https://www.allerstorfer.at/roundcube-nachricht-als-spam-markieren/ | ||
[[Kategorie:Roundcube/Plugin]] | |||
Aktuelle Version vom 27. August 2023, 15:27 Uhr
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 and spamassassin in cascade. Be aware that you have to eventually remove shell_exec from disable_functions in your php.ini so that php 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 to SpamAssassin, allowing it to 'learn' what signs are likely to mean spam. The latter one reports the mail as spam to Razor, Pyzor and Spamcop.
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 to SpamAssassin, allowing it to 'learn' which signs are likely to mean ham. The latter one revoke the report to Razor. Apparently the revocation is not possible with Pyzor and Spamcop (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 to apache in the log dir and to Razor's identity-* files, as Roundcube 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
markasjunk2plugin multi_driverplugin 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 run sa_blacklist followed by cmd_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's multi_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.