[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Sieve, problem backing up mail
From: |
Sergey Poznyakoff |
Subject: |
Re: Sieve, problem backing up mail |
Date: |
Sat, 14 Jun 2025 12:39:07 +0200 |
User-agent: |
MH (GNU Mailutils 3.17.90) |
Hi Steve,
Sergey Poznyakoff <gray@gnu.org.ua> wrote:
> In contrast to mbsync, sieve is not a mail synchronization tool, and
> it does not use uids to track which mails have been processed and
> which haven't. The solution would be [...] to implement an extension
> to sieve that would make it uid-aware.
I have implemented it (commit 3ac02a0690). Please, pull. The extension
is implemented as an external (dynamically loaded) test, called
"uidnew". The test evaluates to true if the current message has not
been processed before and to false otherwise. The usage is:
require "test-uidnew"; # This loads the test.
if uidnew {
/* New message: process it */
...
}
Thus, your original sieve filter can be modified as follows:
require ["fileinto", "variables", "test-uidnew"];
set "folder" "maildir:///path/to/mbsync/account";
if uidnew
{
if exists "to"
{
fileinto "${folder}/backup-allmail";
keep;
}
}
A couple of points to note. The extension keeps track of processed
messages in a GDBM file ".uidnew.db", located in your home directory.
If you wish to use another location (or another DBM flavor, if supported
by mailutils), use the ":db" tag:
if uidnew :db "~/.tmp/another.db"
{
...
Data stored in the DBM is indexed by the full name of the mailbox
being processed. If the need be, that name can be altered as well, by
using the ":mailbox" tag. This should rarely be needed; I describe it
here just for the sake of consistency.
As usual, your feedback is welcome.
Regards,
Sergey