Is it possible to write a Sieve rule like

if envelope :detail "to" "$x" {
  fileinto "inbox.$x";

but for all possible $x? I.e. if the user created a folder inbox.foo I want mail addressed to user+foo@domain to land there automatically. The spec doesn't seem to support this.

2 Answers 2


Turns out that's what the variables extension is for.

require "variables";
if envelope :detail :matches "to" "*" {
  fileinto "inbox.${1}";

For me this one worked:

require ["variables", "fileinto", "envelope", "subaddress", "mailbox"];

if envelope :matches :detail "to" "*" {
    # you can prefix with INBOX/ or INBOX. if necessary
    # remove :create if you want to permit only existing mailboxes
    fileinto :create "${1}";

See the example from here: https://wiki.dovecot.org/Pigeonhole/Sieve/Examples

Obviously this would also be just an option to be turned on: lmtp_save_to_detail_mailbox=yes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.