Re: [sieve] Fwd: New Version Notification for draft-bosch-sieve-duplicate-01.txt

Stephan Bosch <> Tue, 12 March 2013 21:14 UTC

Return-Path: <>
Received: from localhost (localhost []) by (Postfix) with ESMTP id 322DC21F896E for <>; Tue, 12 Mar 2013 14:14:39 -0700 (PDT)
X-Virus-Scanned: amavisd-new at
X-Spam-Flag: NO
X-Spam-Score: 0.24
X-Spam-Status: No, score=0.24 tagged_above=-999 required=5 tests=[AWL=0.744, BAYES_00=-2.599, HELO_EQ_NL=0.55, HOST_EQ_NL=1.545]
Received: from ([]) by localhost ( []) (amavisd-new, port 10024) with ESMTP id bh5h4AfGiMeM for <>; Tue, 12 Mar 2013 14:14:38 -0700 (PDT)
Received: from ( []) by (Postfix) with ESMTP id 7592721F896D for <>; Tue, 12 Mar 2013 14:14:37 -0700 (PDT)
Received: from ([]:50569 helo=[]) by with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.72) (envelope-from <>) id 1UFWWm-0008FG-W5; Tue, 12 Mar 2013 22:14:34 +0100
Message-ID: <>
Date: Tue, 12 Mar 2013 22:14:06 +0100
From: Stephan Bosch <>
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3
MIME-Version: 1.0
To: Alexey Melnikov <>
References: <> <> <> <>
In-Reply-To: <>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-RenameIT-MailScanner-SpamScore: -2.3 (--)
X-RenameIT-MailScanner-SpamCheck: No, score=-2.3 required=5.0 tests=ALL_TRUSTED, BAYES_00 autolearn=ham version=3.3.1
Cc: Sieve mailing list <>
Subject: Re: [sieve] Fwd: New Version Notification for draft-bosch-sieve-duplicate-01.txt
X-Mailman-Version: 2.1.12
Precedence: list
List-Id: SIEVE Working Group <>
List-Unsubscribe: <>, <>
List-Archive: <>
List-Post: <>
List-Help: <>
List-Subscribe: <>, <>
X-List-Received-Date: Tue, 12 Mar 2013 21:14:39 -0000

Hi Alexey,

On 3/10/2013 3:01 PM, Alexey Melnikov wrote:
> On 9 Mar 2013, at 11:08, Stephan Bosch <> wrote:
>> I made a new version of the "duplicate" draft. It should address the comments by Ned and Alexey.
>> Any thoughts about this?
> This looks much better, thank you.
> One new issue is that I don't understand how :value works. Maybe it is a Sunday morning effect. Maybe you can show an example or two?

To detect duplicates, some more or less unique identifying string value 
must be extracted from the message and compared between deliveries. For 
most cases, the contents of the Message-ID header is the best choice; 
that is what it is meant for. However, to accommodate more complex uses, 
the duplicate test has the flexibility to choose a different string 
value for comparison. Using the :value argument, the string value can be 
set manually to an arbitrary string. Typically, one would compose this 
string using variable substitutions. One can for example compose it from 
parts of a header, the envelope, multiple headers, parts of the message 
body or even the current date; whatever is appropriate for the application.

There is one example of the use of :value in the draft (the second one). 
I should perhaps make the subject header structure a bit more complex to 
justify its use in this example (because :header would work here as well).

Another example would be the following scenario. A mail user receives 
XMPP notifications about new mail through Sieve. Sometimes a single 
contact sends many messages in a short period of time and the user wants 
to prevent being notified of all of those messages. He wants to be 
notified about messages from each person at most once per 30 minutes. He 
writes the following script:

require ["variables", "envelope","enotify", "duplicate"];

if envelope :matches "from" "*" { set "sender" "${1}"; }
if header :matches "subject" "*" { set "subject" "${1}"; }

if not duplicate :seconds 1800 :value "${sender}") {
     notify :message "[SIEVE] ${from}: ${subject}" 

So this example uses the message envelope sender rather than the 
Message-ID header as an identifier for duplicate checking.

This example can be extended to allow multiple messages from the same 
sender in close succession as long as the discussed topic is different. 
This could be done as follows:

require ["variables", "envelope","enotify", "duplicate"];

if envelope :matches "from" "*" { set "sender" "${1}"; }
if header :matches "subject" "*" { set "subject" "${1}"; }

if string :comparator "i;ascii-casemap" :matches "${subject}" "Re:*" {
     set "topic" "${1}";
} else {
     set "topic" "${subject}";

if not duplicate :seconds 1800 :value "${sender} ${topic}") {
     notify :message "[SIEVE] ${from}: ${topic}" "";