ProtonMail/libsieve-php

Usage example

bookmoons opened this issue · 2 comments

Is there an example of usage of this library?

I'd like to use it to add mail filtering to nextcloud nextcloud/mail#44.

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.

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