Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions docs/core/config/sieve/extensions/duplicate.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,32 @@ sieve_script personal {
sieve_duplicate_default_period = 1h
sieve_duplicate_max_period = 1d
```

## Sieve Example

```sieve
require ["duplicate"];

if duplicate {
discard;
stop;
}
```

This example discards duplicate messages based on the default message ID tracking.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about "default Message-ID header based tracking.


## Advanced Sieve Example

```sieve
require ["duplicate", "fileinto"];

if duplicate :header "Message-ID" {
fileinto "Duplicates";
stop;
}

fileinto "Inbox";
```

This example uses the `Message-ID` header explicitly and files duplicate
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets use some example that makes more sense. ChatGPT suggests:

require ["duplicate", "imap4flags"];

# If the subject starts with "ALERT:", check for duplicates based on the full subject
if header :matches "Subject" "ALERT: *" {
    if duplicate :seconds 60 :header "Subject" {
        setflag "\\seen";
    }
}

messages into a dedicated mailbox instead of discarding them.
12 changes: 12 additions & 0 deletions docs/core/config/sieve/extensions/editheader.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,15 @@ sieve_editheader_header X-Seen {
forbid_delete = yes
}
```

## Sieve Example

```sieve
require ["editheader"];

deleteheader "X-Spam-Flag";
addheader "X-Processed-By" "Dovecot Sieve";
```

This example removes an existing header field and adds a new header field to
mark the message as processed.
11 changes: 11 additions & 0 deletions docs/core/config/sieve/extensions/include.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,14 @@ The include extension is available by default.
### Settings

<SettingsComponent tag="sieve-include" level="3" />

## Sieve Example

```sieve
require ["include"];

include :personal "spam_rules";
```

This example includes a personal Sieve script named `spam_rules` from the
user's script storage.
13 changes: 13 additions & 0 deletions docs/core/config/sieve/extensions/spamtest_virustest.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,16 @@ sieve_virustest_text_value {
}
```
:::

## Sieve Example

```sieve
require ["spamtest", "fileinto", "relational", "comparator-i;ascii-numeric"];

if spamtest :value "ge" :comparator "i;ascii-numeric" "5" {
fileinto "Spam";
}
```

This example files messages into the Spam folder when the spam score
meets or exceeds the configured threshold.
12 changes: 12 additions & 0 deletions docs/core/config/sieve/extensions/vacation.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,3 +109,15 @@ sieve_vacation_default_period = 10d
# Thirty days at maximum
sieve_vacation_max_period = 30d
```

## Sieve Example

```sieve
require ["vacation"];

vacation :days 7
:subject "Out of office"
"I am currently away and will reply when I return.";
```

This example sends an automatic reply at most once every 7 days per sender.
17 changes: 17 additions & 0 deletions docs/core/config/sieve/extensions/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,20 @@ The variables extension is available by default.
### Settings

<SettingsComponent tag="sieve-variables" level="3" />

## Sieve Example

```sieve
require ["variables", "header", "fileinto"];

if header :matches "Subject" "*" {
set "subject" "${1}";
}

if string :contains "${subject}" "report" {
fileinto "Reports";
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example's usage of variables extension is rather unnecessary, since it could be directly matching the subject. ChatGPT suggests:

require ["variables", "header", "fileinto"];

# 1. Use wildcards to capture the tag inside brackets
# Example: "[Support] Help needed" matches "Support" into ${1}
if header :matches "Subject" "[*] *" {
    
    # 2. Normalize the tag to lowercase
    set :lower "tag" "${1}";

    # 3. Use an explicit list to ensure you only file into existing folders
    if string :is "${tag}" ["urgent", "receipts", "travel"] {
        fileinto "Folders/${tag}";
    }
}

```

This example extracts the Subject header into a variable and files matching
messages into a folder based on its contents.
11 changes: 11 additions & 0 deletions docs/core/plugins/sieve_extprograms.md
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,14 @@ the sender address and a time interval specified in seconds. The time
interval is used to specify the minimum amount of time that needs to have
passed since the sender was last seen. If the script returns exit code 0,
then message is redirected in the Sieve script shown above.

## Sieve Example

```sieve
require ["vnd.dovecot.pipe"];

pipe "process-message";
```

This example pipes the message to an external program named
`process-message`, which must be configured and available via the plugin.
Loading