Skip to content

feature request: Move spam to mailbox associated to the \Junk special-use attribute #3918

@kirirururu

Description

@kirirururu

Context

For now, I can rename Junk mailbox (and others) as described in documentation. But additional changes may be necessary, namely replacing 'Junk' string to selected mailbox name in two other files:

  1. If MOVE_SPAM_TO_JUNK=1, in file /usr/lib/dovecot/sieve-global/after/spam_to_junk.sieve
  2. If RSPAMD_LEARN=1, in file /etc/dovecot/conf.d/90-sieve.conf

This can be done in user-patches.sh using, for example, sed utility. But I think we can do better.

Description

Dovecot 2.3 added support for RFC 8579. If we enable Sieve extension 'special-use', we can rewrite spam_to_junk.sieve as follows:

require ["fileinto","special-use"];

if anyof (header :contains "X-Spam-Flag" "YES",
          header :contains "X-Spam" "Yes") {
    fileinto :specialuse "\Junk" "Junk";
}

This will eliminate the need to patch the file spam_to_junk.sieve.

Unfortunately, some changes in IMAPSieve plugin required to solve the problem with 90-sieve.conf (allowing to specify special-use attribute in imapsieve_mailboxXXX_name and imapsieve_mailboxXXX_from settings). I've already suggested this feature in Dovecot mailing list and waiting for reply.

Alternatives

Of course, instead we can add new configuration parameter like JUNK_MAILBOX_NAME in docker-mailserver. But what will happen, if user rename Junk mailbox and forget to set/change this parameter?

Applicable Users

Users, who rename Junk mailbox on their servers (for translation purpose or because they just prefer 'Spam' over 'Junk').

Are you going to implement it?

Yes, because I know the probability of someone else doing it is low and I can learn from it.

What are you going to contribute?

I've tested changes to spam_to_junk.sieve on recent version of docker-mailserver, and it works.
For some reason I can not run project tests locally. I can successfully build image, but when I run make clean tests I get this error:
The directory named as part of the path /var/log/mail/rspamd.log does not exist in section 'program:rspamd' (file: '/etc/supervisor/conf.d/dms-services.conf')
What am I doing wrong?

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions