Subfolder in sieve not working as expected

Kees van Vloten keesvanvloten at gmail.com
Wed Nov 17 13:18:42 UTC 2021


On 17-11-2021 09:38, Remy Zandwijk wrote:
>> On 16 Nov 2021, at 21:43, Kees van Vloten <keesvanvloten at gmail.com> wrote:
>>
>> On 15-11-2021 23:04, dovecot at ptld.com wrote:
>>>>> On 11-15-2021 3:46 pm, Kees van Vloten wrote:
>>>> I am trying to move incoming mails into subfolders with this sieve script:
>>>>
>>>> require ["fileinto", "variables", "mailbox"];
>>>> if header :matches "Delivered-To" "*@*"
>>>> {
>>>>      fileinto :create "INBOX/${2}";
>>>> }
>>> I am not using variables and my folders are pre-created. But just to give you a starting point, this is what works using maildir++ format with default directory layout.
>>> https://doc.dovecot.org/configuration_manual/mail_location/Maildir/
>>>
>>>     require ["fileinto"];
>>>     # rule:[Dovecot]
>>>     if header :contains "sender" "@dovecot.org"
>>>     {
>>>        fileinto "INBOX.Dovecot";
>>>     }
>> ok, I am trying to start simple:
>>
>> - removed the mail_plugin "listescape"
>>
>> - set mail_location = maildir:%h/%d/%n/Maildir
>>
>> - and changed the sieve script into:
>>
>> require ["fileinto", "variables", "mailbox"];
>>
>> if header :contains "Delivered-To" "@example.com"
>> {
>>      fileinto :create "INBOX.example";
>> }
>>
>> Running sieve from the cmdline returns:
>>
>> error: msgid=<76c62f93-527a-d8d9-f787-65926d9c3e25 at domain.com>: fileinto action: failed to store into mailbox 'INBOX.example': Character not allowed in mailbox name: '.'.
>> sieve-filter(vmail): Info: sieve: msgid=<76c62f93-527a-d8d9-f787-65926d9c3e25 at domain.com>: left message in mailbox 'INBOX'
>>
>> For some reason the :create seems to have a problem with the folder separator '.'
>>
>> Any clue how to get '.example' recognized as a subfolder?
>>
>> - Kees
> In your previous email, you wrote:
>
> separator = ~
>
> You might want to change that to:
>
> separator =
>
> (Which defaults to a dot as mailbox separator)
>
> -Remy
>
It is indeed the separator, thanks Remy!
The confusion came from the different kind of separators defined in 
multiple places and also used in different places.

To summarize:

- Each namespace defines a separator, but you must use the same in all 
namespaces (why isn't this a global setting?).

- Each LAYOUT="<x>" has an implied separator on its storage. Maildir++ 
uses the dot, "fs" uses slash., this is the separator visible on the 
filesystem.

- IMAP has a separator on the wire, which then translates to the LAYOUT 
separator on the filesystem.

- Separator conflicts between imap and layout separator can be avoided 
with the listescape plugin

- To use a dot or a slash in folder names neither one should be used as 
the namespace separator.

- To have IMAP folders stored in a filesystem hierarchy of 
subdirectories LAYOUT=fs should be used.

- As it turns out the namespace separator is the one to be used in sieve 
scripts, whereas I actually used the LAYOUT separator.

In any case where to use what separator was not immediately clear to me. 
The sieve docs and examples on wiki/doc site do not mention the 
namespace separator at all. It would be helpful to put a remark or 
pointer there.
But now it works (famous last words) :-), thanks again.

- Kees





More information about the dovecot mailing list