Subfolder in sieve not working as expected
Hi everybody,
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}"; }
On a message to user@example.com I would expect it to be stored in the folder 'example.com' under 'INBOX', but instead a folder named 'INBOX\2fexample.com' is created. I tried several options:
- replace / with \/ or \\/
- replace / with .
- disable listescape in dovecot.conf Unfortunately nothing did the trick. Any ideas what could fix this?
dovecot -n
# 2.3.13 (89f716dc2): /etc/dovecot/dovecot.conf
# Pigeonhole version 0.5.13 (cdd19fe3)
# OS: Linux 5.10.0-9-amd64 x86_64 Debian 11.1
# Hostname: servers.example.com
auth_default_realm = EXAMPLE.COM
auth_gssapi_hostname = servers.example.com
auth_krb5_keytab = /etc/keytab/dovecot.keytab
auth_master_user_separator = *
auth_mechanisms = gssapi gss-spnego plain
auth_realms = EXAMPLE.COM
first_valid_gid = 986
first_valid_uid = 990
imap_client_workarounds = tb-extra-mailbox-sep
login_greeting = Dovecot ready.
mail_debug = yes
mail_gid = 986
mail_location =
maildir:%h/%d/%n/store:LAYOUT=fs:FULLDIRNAME=0_FolderContent:UTF-8:INDEX=%h/%d/%n/index:CONTROL=%h/%d/%n/control:VOLATILEDIR=%h/%d/%n/volatile
mail_plugins = zlib notify push_notification listescape acl
mail_privileged_group = mail
mail_shared_explicit_inbox = yes
mail_uid = 990
managesieve_notify_capability = mailto
managesieve_sieve_capability = fileinto reject envelope
encoded-character vacation subaddress comparator-i;ascii-numeric
relational regex imap4flags copy include variables body enotify
environment mailbox date index ihave duplicate mime foreverypart
extracttext vacation-seconds spamtest imapflags notify imapsieve
vnd.dovecot.imapsieve
namespace inbox {
inbox = yes
list = yes
mailbox Drafts {
auto = subscribe
special_use = \Drafts
}
mailbox Inbox {
auto = subscribe
}
mailbox Junk {
auto = subscribe
special_use = \Junk
}
mailbox Sent {
auto = subscribe
special_use = \Sent
}
mailbox Trash {
auto = subscribe
special_use = \Trash
}
prefix =
separator = ~
subscriptions = yes
type = private
}
passdb {
args = username_format=%u /etc/dovecot/master-users
driver = passwd-file
master = yes
}
passdb {
args = /etc/dovecot/ldap_user_to_principal.conf.ext
driver = ldap
pass = yes
}
passdb {
driver = pam
}
plugin {
acl = vfile:/var/lib/dovecot/global-acls:cache_secs=1
acl_shared_dict = file:/var/lib/dovecot/shared-mailboxes
autocreate = Trash
autocreate2 = Drafts
autocreate3 = Sent
autosubscribe = Trash
autosubscribe2 = Drafts
autosubscribe3 = Sent
imapsieve_mailbox1_before =
file:/var/lib/dovecot/sieve/imap/learn-spam.sieve
imapsieve_mailbox1_causes = COPY
imapsieve_mailbox1_name = Junk
imapsieve_mailbox2_before =
file:/var/lib/dovecot/sieve/imap/learn-ham.sieve
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_from = Junk
imapsieve_mailbox2_name = *
listescape_char =
sieve = file:%h/%d/%n/sieve/sieve;active=%h/%d/%n/sieve/active.sieve
sieve_after = /var/lib/dovecot/sieve/after
sieve_before = /var/lib/dovecot/sieve/before
sieve_default = /var/lib/dovecot/sieve/default.sieve
sieve_extensions = +vacation-seconds +reject +notify +imapflags +spamtest
sieve_global_extensions = +vnd.dovecot.pipe
sieve_pipe_bin_dir = /var/lib/dovecot/sieve/bin
sieve_plugins = sieve_imapsieve sieve_extprograms
sieve_vacation_default_period = 1d
sieve_vacation_max_period = 1d
sieve_vacation_min_period = 10s
sieve_vacation_use_original_recipient = yes
}
postmaster_address = sysadmin@cvanvloten.nl
protocols = " imap lmtp sieve submission"
service auth {
unix_listener /var/spool/postfix/private/auth {
group = postfix
mode = 0660
user = postfix
}
}
service imap-login {
inet_listener imap {
port = 0
}
inet_listener imaps {
port = 993
ssl = yes
}
process_min_avail = 1
}
service imap {
executable = imap
}
service lmtp {
unix_listener /var/spool/postfix/private/dovecot-lmtp {
group = postfix
mode = 0600
user = postfix
}
}
service submission-login {
inet_listener submission {
port = 465
ssl = yes
}
}
ssl = required
ssl_cert =
- Kees
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"; }
On 15-11-2021 23:04, dovecot@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@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@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
On 16 Nov 2021, at 21:43, Kees van Vloten keesvanvloten@gmail.com wrote:
On 15-11-2021 23:04, dovecot@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@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@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
On 17-11-2021 09:38, Remy Zandwijk wrote:
On 16 Nov 2021, at 21:43, Kees van Vloten keesvanvloten@gmail.com wrote:
On 15-11-2021 23:04, dovecot@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@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@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
participants (3)
-
dovecot@ptld.com
-
Kees van Vloten
-
Remy Zandwijk