Struggling with sieve, fileinto and variables.

Stephan Bosch stephan at rename-it.nl
Wed May 30 15:41:10 EEST 2018



Op 30-5-2018 om 14:01 schreef Barry Pearce:
> Hi,
>
> Im on Manjaro linux fully up to date running
>
>     dovecot 2.3.1-2
>     pigeonhole 0.5.1-2
>
>
> All is running well except I am having problems with fileinto - it 
> refuses to use variables, and mailboxexists is also failing for me.
>
> Im just dealing with plus addressing - should be simple but the 
> behaviour Im experiencing isnt right.
>
>     require ["variables", "envelope", "fileinto", "subaddress",
>     "mailbox"];
>     if envelope :matches :detail "to" "*" {
>         set :lower "name" "${1}";
>     }
>     fileinto :create "folder3";
>
>
> This works, but changing the last line to:
>
>     fileinto :create "${name}";
>
>
> fails and files into inbox. As does:
>
>     fileinto :create "${1}";
>
>
> It makes no difference if the fileinto is placed inside the if 
> statement or otherwise. Using sieve-test suggests the basic scriptit 
> should work and traces show the right action.
>
> On a related matter the script Im actually trying to get to work is:
>
>     require ["variables", "envelope", "fileinto", "subaddress",
>     "mailbox"];
>
>     if envelope :matches :detail "to" "*" {
>         set :lower "name" "${1}";
>     }
>     if mailboxexists "${name}" {
>             fileinto :create "${name}";
>     }
>
>
> But fails and files in the inbox.

This happens for a reason, which you can either find in your syslog or 
in the user log file (e.g. ~/.dovecot.sieve -> ~/.dovecot.sieve.log).


> Modifying the script to:
>
>     require ["variables", "envelope", "fileinto", "subaddress",
>     "mailbox"];
>
>     if envelope :matches :detail "to" "*" {
>         set :lower "name" "${1}";
>     }
>
>     if mailboxexists "${name}" {
>             fileinto :create "folder7";
>     } else {
>       fileinto :create "folder8";
>     }
>
>
> Files into folder8. So the mailboxexists is failing.
>
>      ## Started executing script 'plus-addressing'
>   3: envelope test
>   3:   starting `:matches' match with `i;ascii-casemap' comparator:
>   3:   getting `to' part from message envelope
>   3:   extracting `detail' part from address <test+folder4 at test.net>
>   3:   matching value `folder4'
>   3:     with key `*' => 1
>   3:   finishing match with result: matched
>   3: jump if result is false
>   3:   not jumping
>   4: set command
>   7:   modify :lower "folder4" => "folder4"
>   7:   assign `name' [0] = "folder4"
>   7: mailboxexists test
>   7:   mailbox `folder4' cannot be opened
>   7:   some mailboxes are unavailable
>   7: jump if result is false
>   7:   jumping to line 9
>  10: fileinto action
>  10:   store message in mailbox `folder8'
>      ## Finished executing script 'plus-addressing'
>
> Here folder4 actually does exist - so the sieve-test confirms that 
> issue.  Im at a loss as to whats going on. Im particularly perplexed 
> by the difference in behaviour between sieve-test and the result under 
> the live server.

You can also get a trace for the live server: 
https://wiki2.dovecot.org/Pigeonhole/Sieve/Configuration#Trace_Debugging

Regards,

Stephan.



More information about the dovecot mailing list