Thanks for that. Turns out it was an issue with exim stripping the local part suffix from the envelope before passing over lmtp to dovecot. Fixed in the exim router config!

Although if you turn on trace with spamtest it does result in a crash during mail receipt:

lmtp(test@test.net)<7988><cDK3ADztDls0HwAANIsFaQ>: Panic: Unsupported 0x30 specifier starting at #38 in 'extracted score=%.3f, max=%.3f, ratio=%.0f %%'

lmtp(test@test.net)<7988><cDK3ADztDls0HwAANIsFaQ>: Error: Raw backtrace: /usr/lib/dovecot/libdovecot.so.0(+0xc7e87) [0x7fa1c8cf1e87] -> /usr/lib/dovecot/libdovecot.so.0(+0xc7f4a) [0x7fa1c8cf1f4a] -> /usr/lib/dovecot/libdovecot.so.0(i_fatal+0) [0x7fa1c8c5ebc9] -> /usr/lib/dovecot/libdovecot.so.0(+ [snip...]

lmtp(test@test.net)<7988><cDK3ADztDls0HwAANIsFaQ>: Fatal: master: service(lmtp): child 7988 killed with signal 6 (core not dumped - https://dovecot.org/bugreport.html#coredumps - set /proc/sys/fs/suid_dumpable to 2)


At least my problem is fixed - so thank you!


From: Stephan Bosch <stephan@rename-it.nl>
Sent: 30 May 2018 13:41
To: Barry Pearce; dovecot@dovecot.org
Subject: Re: Struggling with sieve, fileinto and variables.
 


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@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.