maddy icon indicating copy to clipboard operation
maddy copied to clipboard

Sieve filters support

Open emersion opened this issue 6 years ago • 9 comments

https://tools.ietf.org/html/rfc5228

emersion avatar Apr 18 '19 05:04 emersion

Having ManageSieve protocol too would be nice: https://tools.ietf.org/html/rfc5804

Also, found Sieve lang parser for golang: https://github.com/qingshan/sieve. I wonder if it works...

foxcpp avatar Apr 28 '19 19:04 foxcpp

Once sieve filtering has been added, is the possibility of having a [email protected] email that gets emails forwarded into spam folder a reality?

Yes.

emersion avatar May 11 '19 13:05 emersion

Sieve support would be cool. Can't imagine any Imap service without Sieve.

helmut72 avatar May 21 '20 08:05 helmut72

When building WildDuck Mail Server we decided to not use Sieve and instead went with custom filtering system that is applied to incoming emails and is easy to integrate with a web UI. Basically these are If-This-Then-That rules (example). Such filters cover 90% of use cases required by users.

We did not see any value in actual Sieve mostly because it's a separate programming language (so there might be some security issues if a user is able to come up with a complex enough script). Also most users are not able to write it anyway, so usually it ends up being disguised by the UI into simpler forms.

andris9 avatar May 21 '20 10:05 andris9

Sieve has a great upside: it's a standard. So it really helps users switching from an email server to another without having to learn a new filtering DSL and convert all of their filters.

emersion avatar May 21 '20 10:05 emersion

Additionally, Sieve is not Turing-complete (no loops, no functions), so I wouldn't be too worried about complex scripts.

emersion avatar May 21 '20 10:05 emersion

@angelnu idea for a solution

  • Implement ManageSieve in Maddy so users can use their email clients to upload the filter configs to the server this could be either be implemented natively in Go or call existing (but old) Python libraries . The protocol looks simple enough so re-implementing in Go might even be easier so we could reuse the STARTTLS support in Maddy.

  • Add a Sieve parser to Maddy to process the uploaded scripts and generate the scripts out of the sieve configs. Here we could use the C library libsieve as re-implementing in Go might be more work.

foxcpp avatar Feb 01 '22 19:02 foxcpp

I implemented a simple interpreter for the base Sieve specification here: https://github.com/foxcpp/go-sieve.

foxcpp avatar Feb 16 '22 17:02 foxcpp

Once we get support for several important extensions into it and find a way to re-use Pigeonhole tests suite - it should be ready for integration into maddy. Though we will need a several rounds of refactoring to make IMAPFilter interface flexible enough.

foxcpp avatar Feb 16 '22 17:02 foxcpp