Patch for dovecot-antispam-plugin to support IMAP Flags indicating Junk status

Jonas Wielicki jonas at wielicki.name
Fri Nov 25 10:43:41 UTC 2016


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Dear list,

I made a patch which extends dovecot-antispam-plugin with support to take the 
addition and removal of a specific set of flags as trigger for learning.

This allows for very tight integration with Thunderbird and KMail, which both 
set flags for Junk messages (Thunderbird sets "Junk", KMail sets "JUNK"). With 
this patch and according configuration, dovecot-antispam-plugin can trigger on 
the addition (learn as spam) and removal (learn as ham) of these flags.

Combined with a sieve script which sets these flags for incoming mail which 
has been classified as spam, this allows for a tight and intuitive feedback 
loop between users and the server-side spam classification system.

I tested that patch with dovecot 2.2 from Debian stretch and so far it works 
pretty well.


I realise that dovecot-antispam-plugin has not been updated since 2013. It 
also has not been migrated to Github yet. If it is to be migrated there, I 
would be happy to submit a pull request there for discussion and merging. 
Otherwise, someone would have to indicate how to go forward with applying this 
patch to the official version, if that is desired.


The patch is based on current tip and feedback is appreciated. I took some 
inspiration from dovecot-core/src/plugins/notify/notify-storage.c -- this 
requires the use of struct mail_private to be able to override the vfunc for 
mail_update_keywords, which I actually do not like. However, when I tried to 
make this patch base on the use of the notify plugin (via notify_register), I 
ran into the issue that the transaction is partially freed before the 
transaction_commit event from notify is emitted, which is unfortunate and 
breaks at least the mailtrain backend (which I use). This is in theory 
fixable, but I wanted to keep the patch as small as possible, as I have no 
idea whether this will eventually end up upstream or whether I’ll have to 
maintain that for myself.


If upstream is not interested in this patch, please let me know! In that case, 
I would consider making an own plugin, which fewer backends (possibly only a 
mailtrain-like one) out of this, but frankly, I would consider that a waste of 
resources. 


In the hope that this is useful for others and hoping for feedback,
Jonas Wielicki
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEG/EPV+Xzd5wEoQQIwGIDJZdiWIoFAlg4Fd0ACgkQwGIDJZdi
WIpM3Q//TWVHDFx5LK14y0jOnxzE7kGthc6hakILnWqYgl7B/wlljD1HLrec//hg
9LEancjURnv3sPU/kEEpl6RRDX5kDMbXXKXMq7/1R7bNdmeMz5NEebAo7ktlCii7
ikk7MPL0F8UViY7IoW7y5NxfqMUldYseejn0GwKiVkEyqlyGLRbP7ijyzMWjpIWp
eqOg/b5bNX6ARMC1O/hKhvHw4AhvSO2j73da60Xchu39gvDa2kC+MTU/kX4wb6po
kPOEgFxGhpxG0+UMzUEBPLYwY3Q9x+R/PzlpUF6xEjYxgE7leVRVfCHiZLsMUGH1
itozwSzoAyDYV+Rbzk8OEBL6EGBJQHqYmNybULZsJkxhUenNeC4GRf7NcJ0jAisG
rSfwr/+kD9+ErKNgtNJzfceLYGNWti44whV6kXxRxqGlIfJsJB7ZMdrj8+wSdn0p
slXUoyHMUkRkN92tIPqZF5cb+5Ke+O+5hHE07Wohxw3eNoBSqtQWo81aigjaCraC
ivcZX3HswTapyKtpgWMzjoWqp982crr+wtAI+AlEUKoCEqF54EnxM1kB1qoe0HcH
nMgMdIkXI4VzPaUNUK206ffEtlnKNIqF3SkOkBX263L0ZJgXyCFRRj6W3z78VDdP
He62tN/FPPBtmeVrmCj2ZDE+6gqtMQN52FsN4mpaq4BrCYlYB7g=
=3+CU
-----END PGP SIGNATURE-----
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Trigger-learning-on-change-of-configurable-IMAP-Flag.patch
Type: text/x-patch
Size: 7147 bytes
Desc: not available
URL: <http://dovecot.org/pipermail/dovecot/attachments/20161125/820e632f/attachment.bin>


More information about the dovecot mailing list