cozy / cozy-emails

Email Client for Cozy
GNU Affero General Public License v3.0
66 stars 41 forks source link

Allow to use Sieve filters #103

Open clochix opened 9 years ago

clochix commented 9 years ago

Sieve is a popular way to filter emails on server side. It's both

We can't assume the remote server allows to manage filters, so we should probably allow the user to upload some Sieve scripts into the Email application, and apply the filters on our side.

A lot of tools exist that allow to play with Sieve. Unfortunately:

I had a look at http://sieve.info/libraries but didn't find something we could reuse to easily implement Sieve filters inside CozyMails. GNU/Mailutils offers a command-line tool that allow to filter emails, but it seems to only be able to operate on local mailboxes, not thru IMAP.

If we want to use Sieve, I thing the best choice would be to use the libsieve library, available in Debian. It's source code embed some tests using a command line client. We can use this sample program, running it on every message and parsing the output. Or we can get some inspiration from the test program to write a nodejs wrapper (but it won't be easy). See https://packages.debian.org/source/sid/libsieve (Version shipped with Debian is pretty old but I'm unable to compile the latest from https://github.com/sodabrew/libsieve)

See also:

m4dz commented 9 years ago

Maybe we can implement those filtering capabilities in to complementaries way:

  1. If the IMAP server supports SIEVE filtering (available behind a dedicated sieve port), then filtering is executed remotely, and CozyMail just pass scripts to IMAP server through ManageSieve protocol
  2. If the IMAP server does not, so filtering is executed locally inside CozyMail, using the SIEVE scripts or not.

This way, we can implement filtering in two times, taking care of IMAP capabilities. We also can have a single unified interface to editing filtering rules that generates scripts for ManageSieve, or just apply filtering locally using the internal selected protocol. For users, it's transparent and do not rely on a technical background (aka "I don't want to editing sieve filters myself, it's too boring"). Also, we can provide an advanced view we users can simply copy/paste their already designed sieve scripts that can be read and used by CozyMai.

My 2cts :wink:…