Hi,
can dovecot sieve query any external database ( berkeley database file, rest api, whatever) to determine the target folder by sender address?
Background:
I have to migrate a mailbox from an old ubuntu system running with mailfilter as a local delivery agent, and dovecot just as an IMAP server.
Since recent ubuntu versions do not have mailfilter anymore (abandoned for a decade) I need to substitute the mailfilter file with dovecot sieve.
The old mailfilter script contained something like
if (gdbmopen(".mailfilter.gdbm", "R") == 0) { if ( (box=gdbmfetch(tolower($FROM),"D")) ne "" ) to $box
if ( /^From: .*<(.*)>/ ) { if ( (box=gdbmfetch(tolower($MATCH1),"D")) ne "" ) to $box }
gdbmclose }
which allowed to sort mails into mailboxes depending on the sender for hundreds of sender addresses in a fast end efficient way.
It wouldn't make sense and be too slow to translate this into a sieve script with a thousand
if header :matches ...
elsif header :matches
...
Is there a way to do this efficently in dovecot's sieve?
regards
Hadmut
at that point, why not run scripts already?
On October 5, 2025 12:54:48 AM GMT+03:00, Hadmut Danisch via dovecot <dovecot@dovecot.org> wrote:
Hi,
can dovecot sieve query any external database ( berkeley database file, rest api, whatever) to determine the target folder by sender address?
Background:
I have to migrate a mailbox from an old ubuntu system running with mailfilter as a local delivery agent, and dovecot just as an IMAP server.
Since recent ubuntu versions do not have mailfilter anymore (abandoned for a decade) I need to substitute the mailfilter file with dovecot sieve.
The old mailfilter script contained something like
if (gdbmopen(".mailfilter.gdbm", "R") == 0) { if ( (box=gdbmfetch(tolower($FROM),"D")) ne "" ) to $box
if ( /^From: .*<(.*)>/ ) { if ( (box=gdbmfetch(tolower($MATCH1),"D")) ne "" ) to $box }
gdbmclose }
which allowed to sort mails into mailboxes depending on the sender for hundreds of sender addresses in a fast end efficient way.
It wouldn't make sense and be too slow to translate this into a sieve script with a thousand
if header :matches ...
elsif header :matches
...
Is there a way to do this efficently in dovecot's sieve?
regards
Hadmut
dovecot mailing list -- dovecot@dovecot.org To unsubscribe send an email to dovecot-leave@dovecot.org
On Sun, Oct 05, 2025 at 07:34:14AM +0300, Sulev-Madis Silber via dovecot wrote:
at that point, why not run scripts already?
Because I wanted to do it just straigthforward, keep things together in one place, not open a new djungle of error sources and complications, and not run a new process for every single mail that comes in.
And because I'd consider this as the MDA's task and wouldn't love to attach external scripts just to help it do it's job.
And because if I had to do everything with a self written script, I wouldn't bother to use dovecot's sieve at all and just use my script.
:-)
participants (2)
-
Hadmut Danisch
-
Sulev-Madis Silber