Skip to content

sieve: Add examples#1501

Open
cmouse wants to merge 1 commit intodovecot:mainfrom
cmouse:sieve-examples
Open

sieve: Add examples#1501
cmouse wants to merge 1 commit intodovecot:mainfrom
cmouse:sieve-examples

Conversation

@cmouse
Copy link
Copy Markdown
Contributor

@cmouse cmouse commented Apr 9, 2026

JIRA: DOV-8101

}
```

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.

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";
    }
}


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}";
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants