From 54f218137990553faa4fed8a29ee8e9d6a68af45 Mon Sep 17 00:00:00 2001 From: Moritz Poldrack <33086936+mpldr@users.noreply.github.com> Date: Thu, 17 Feb 2022 17:32:21 +0100 Subject: [PATCH] added sieve example for subaddress sorting (#2410) --- docs/content/config/advanced/mail-sieve.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/content/config/advanced/mail-sieve.md b/docs/content/config/advanced/mail-sieve.md index f93edb2b..962c150e 100644 --- a/docs/content/config/advanced/mail-sieve.md +++ b/docs/content/config/advanced/mail-sieve.md @@ -61,6 +61,23 @@ pipe "external-program"; For more examples or a detailed description of the Sieve language have a look at [the official site](http://sieve.info/examplescripts). Other resources are available on the internet where you can find several [examples](https://support.tigertech.net/sieve#sieve-example-rules-jmp). +## Automatic Sorting Based on Subaddresses + +It is possible to sort subaddresses such as `user+mailing-lists@example.com` into a corresponding folder (here: `INBOX/Mailing-lists`) automatically. + +```sieve +require ["envelope", "fileinto", "mailbox", "subaddress", "variables"]; + +if envelope :detail :matches "to" "*" { + set :lower :upperfirst "tag" "${1}"; + if mailboxexists "INBOX.${1}" { + fileinto "INBOX.${1}"; + } else { + fileinto :create "INBOX.${tag}"; + } +} +``` + ## Manage Sieve The [Manage Sieve](https://doc.dovecot.org/admin_manual/pigeonhole_managesieve_server/) extension allows users to modify their Sieve script by themselves. The authentication mechanisms are the same as for the main dovecot service. ManageSieve runs on port `4190` and needs to be enabled using the `ENABLE_MANAGESIEVE=1` environment variable.