README.md
1Roundcube Webmail MarkAsJunk Plugin
2===================================
3This plugin adds "mark as spam" or "mark as not spam" button to the message
4menu.
5
6When not in the Junk mailbox:
7 Messages are moved into the Junk mailbox and marked as read
8
9When in the Junk mailbox:
10 The buttons are changed to "mark as not spam" or "this message is not spam"
11 and the message is moved to the Inbox
12
13
14License
15-------
16
17This plugin is released under the [GNU General Public License Version 3+][gpl].
18
19Even if skins might contain some programming work, they are not considered
20as a linked part of the plugin and therefore skins DO NOT fall under the
21provisions of the GPL license. See the README file located in the core skins
22folder for details on the skin license.
23
24
25Configuration
26-------------
27
28The default config file is plugins/markasjunk/config.inc.php.dist
29Rename this to plugins/markasjunk/config.inc.php
30
31All config parameters are optional.
32
33
34The Learning Driver
35-------------------
36
37The learning driver allows you to perform additional processing on each message
38marked as spam/ham. A driver must contain a class named markasjunk_{driver
39file name}. The class must contain 3 functions:
40
41**spam:** This function should take 2 arguments: an array of UIDs of message(s)
42being marked as spam, the name of the mailbox containing those messages
43
44**ham:** This function should take 2 arguments: an array of UIDs of message(s)
45being marked as ham, the name of the mailbox containing those messages
46
47**init:** Optional, this function should take 0 arguments. eg: allows drivers
48to add JS to the page to control which of the spam/ham options are displayed.
49The `jsevents` driver is available to show how to use the JS events.
50
51Several drivers are provided by default they are:
52
53**cmd_learn:** This driver calls an external command (for example salearn) to
54process the message
55
56**dir_learn:** This driver places a copy of the message in a predefined folder,
57for example to allow for processing later
58
59**email_learn:** This driver emails the message either as an attachment or
60directly to a set address. This driver requires Roundcube 1.4 or above.
61
62**sa_blacklist:** This driver adds the sender address of a spam message to the
63users blacklist (or whitelist of ham messages) Requires SAUserPrefs plugin
64
65**amavis_blacklist:** This driver adds the sender address of a spam message to
66the users blacklist (or whitelist of ham messages) Requires Amacube plugin.
67Driver by Der-Jan
68
69**sa_detach:** If the message is a Spamassassin spam report with the original
70email attached then this is detached and saved in the Inbox, the spam report is
71deleted
72
73**edit_headers:** Edit the message headers. Headers are edited using
74preg_replace.
75
76**WARNING:** Be sure to match the entire header line, including the name of the
77header, and include the ^ and $ and test carefully before use on real messages.
78This driver alters the message source
79
80
81Running multiple drivers
82------------------------
83
84**WARNING:** This is very dangerous please always test carefully. Run multiple
85drivers at your own risk! It may be safer to create one driver that does
86everything you want.
87
88It is possible to run multiple drivers when marking a message as spam/ham. For
89example running sa_blacklist followed by cmd_learn or edit_headers and
90cmd_learn. An [example multi-driver][multidriver] is available. This is a
91starting point only, it requires modification for individual cases.
92
93
94Spam learning commands
95----------------------
96
97Spamassassin:
98
99```sa-learn --spam --username=%u %f``` or
100```sa-learn --spam --prefs-file=/var/mail/%d/%l/.spamassassin/user_prefs %f```
101
102
103Ham learning commands
104---------------------
105
106Spamassassin:
107
108```sa-learn --ham --username=%u %f``` or
109```sa-learn --ham --prefs-file=/var/mail/%d/%l/.spamassassin/user_prefs %f```
110
111
112edit_headers example config
113---------------------------
114
115**WARNING:** These are simple examples of how to configure the driver options,
116use at your own risk
117
118```php
119$config['markasjunk_spam_patterns'] = array(
120 'patterns' => array('/^(Subject:\s*)(.*)$/m'),
121 'replacements' => array('$1[SPAM] $2')
122);
123```
124
125```php
126$config['markasjunk_ham_patterns'] = array(
127 'patterns' => array('/^(Subject:\s*)\[SPAM\](.*)$/m'),
128 'replacements' => array('$1$2')
129);
130```
131
132[gpl]: https://www.gnu.org/licenses/gpl.html
133[multidriver]: https://gist.github.com/johndoh/8173505
134