Hi Johannes,
Interesting idea, but the keyword my evolution uses seems to be "Junk", not "$Junk".
You are right, I didn't checked it and copied "$Junk" from http://wiki.dovecot.org/MailboxFormat/Maildir
There isn't really, without some work. I have just committed this patch: http://git.sipsolutions.net/?p=dovecot-antispam.git;a=commitdiff;h=a5941271d... which will doesn't work yet but illustrates the concept (by debugging stuff to the syslog rather than calling the backend.) The new setting "antispam_spam_keywords" isn't documented yet but needs to be set for the keyword code to be invoked at all.
Great!
I guess that in need_keyword_hook case save_init/save_finish hooks will have to check email for spams and keyword it. It is not clear how to mark mail as spam if both need_folder_hook and need_keyword_hook are true.
One problem with this is that evolution doesn't sync the keywords to the server right away, only when you change folders. Also, it's not entirely obvious what the code should do when the backend fails since there doesn't seem to be a way to roll back the keyword change easily. Any comments on the code would be appreciated, and you can probably easily make it invoke the backend with what's there to actually test it.
If I understand how it works with folders -- if message is moved from/to spam folder and spam learning fails, dovecot-antispam rolls back the IMAP transaction and dovecot reports error to client? (sorry if I am wrong, didn't read code nor IMAP specification, just assuming).
Then I think it would be correct to do exactly same with keywords and let client handle error. I am not sure if Evolution would handle that...
Jan