ProtonMail / libsieve-php

libsieve-php is a library to manage and modify sieve (RFC5228) scripts. It contains a parser for the sieve language (including extensions) and a client for the managesieve protocol. It is written entirely in PHP 8+.
https://packagist.org/packages/protonlabs/libsieve-php
GNU General Public License v3.0
21 stars 7 forks source link

Usage example #9

Closed bookmoons closed 5 years ago

bookmoons commented 6 years ago

Is there an example of usage of this library?

I'd like to use it to add mail filtering to nextcloud https://github.com/nextcloud/mail/issues/44.

ThHareau commented 5 years ago

Hi @bookmoons We just updated the readme to include two examples. Could you have a look?

In our code, we use this library mainly to check the lexical and syntaxical correctness of the user input. Then we loop over all the tokens (as in example 2) and we convert the tree in an executable node. The main root can be executed against a message. An if node would be another executable node, which would trigger the then block in case of success, and the else block in case of failure. The discard action would delete the message and stop the scripts. When the user receive a message, we execute the root node.

bookmoons commented 5 years ago

Thanks a lot for the extensive examples. Will be going over them in detail to help with this.