email: Make rspamd learn spam/ham when the user marks mails as junk or not junk.
Add two sieve scripts for spam/ham learning. When the user moves a mail from anywhere to junk, or from junk to anywhere (except for trash) the mail is piped into the respective rspamc learn_spam/learn_ham command. The rspamc command is run as the mail user and the command requires that the user can connect to localhost:11334. Because of that, add the mail user to the allowed users that can access protected services.
The sievec compilation of the new scripts requre the dovecot-antispam package, so install it and increment the email version number.
Closes: #2487 (closed) Imroves: #56
Tests done:
- Apply the patches on an existing install
- Confirm the firewall and the email app get updated
- Move a mail from inbox to junk and confirm that rspamd statistics for "Learned" mails increment by one.
- Move back the mail from junk to inbox and confirm the number increments again.
- Move the mail to trash and confirm the script doesn't execute.
- Repeat steps 3-5 with mail_debug = yes in /etc/dovecot/dovecot.conf and confirm the script esxecution further by reading the debug logs.
Signed-off-by: Benedek Nagy contact@nbenedek.me