[Sieve] Understand Sieve processing

Stephan Bosch
Wed, 07 Apr 2021 00:02:14 -0000

On 26/03/2021 08:30, h8h wrote:
> Hi,
>
> I have the following configuration:
>
>> cat > /etc/dovecot/conf.d/99-local-sieve.conf << EOF;
>> plugin {
>> ?sieve_before = /etc/dovecot/sieve-spam.sieve
>> ?sieve_before2 = /mail/sieve/global_before
>> ?sieve_after = /mail/sieve/global_after
>> ?sieve = /mail/sieve/%d/%n.sieve
>> ?sieve_dir = /mail/sieve/%d/%n
>> }
>> EOF
>
>> cat /etc/dovecot/sieve-spam.sieve
>> require ["regex", "fileinto",
"imap4flags"];
>>
>> if allof (header :regex "X-Spam-Status" "^Yes") {
>> ?fileinto "Spam";
>> }
>
> (I removed the keyword "stop;" to proceed rule processing, which
does
> not work)
>
>
> Now as a user (/mail/sieve/%d/%n.sieve) I want to create my own
"Spam"
> rule:
>> require ["regex","reject"];
>> # rule:[SPAM]
>> if allof (header :regex "x-spam-status" "^Yes")
>> {
>> ?????? reject text:
>> This E-Mail is SPAM.
>> .
>> ;
>> }
>
>
>
> I activate the traces and see the following if the e-mail is SPAM:
>
>> ???? ## Started executing script 'sieve-spam'
>> ? 3: jump if result is false
>> ? 3:?? not jumping
>> ? 4: fileinto action
>> ? 4:?? store message in mailbox `Spam'
>> ???? ## Finished executing script 'sieve-spam'
>
>
> If the e-mail is not SPAM:
>> ???? ## Started executing script 'sieve-spam'
>> ? 3: jump if result is false
>> ? 3:?? jumping to line 4
>> ???? ## Finished executing script 'sieve-spam'
>>
>>
>> ???? ## Started executing script 'roundcube'
>> ? 3: jump if result is false
>> ? 3:?? jumping to line 10
>> ???? ## Finished executing script 'roundcube'
>
> So my sieve gets only executed if the e-mail is not SPAM. Thats a bit
> odd.
>
> Could you explain how the sieve processing work and how I can solve
> this problem?

The fileinto action cancels the implicit keep
(https://tools.ietf.org/html/rfc5228#section-2.10.2). There is no
explicit action in sieve-spam either, so Sieve execution ends there:

https://tools.ietf.org/html/draft-degener-sieve-multiscript-00

Regards,

Stephan.