mailcow / mailcow-dockerized

mailcow: dockerized - 🐮 + 🐋 = 💕
https://mailcow.email
GNU General Public License v3.0
8.91k stars 1.17k forks source link

Complex Sieve filters situation, lack of easy IMAPsieve support #5036

Open plantroon opened 1 year ago

plantroon commented 1 year ago

Summary

Currently, mailcow has multiple places where Sieve filters can be managed and they don't seem well connected or organized:

Then there is a feature called imapsieve - which allows actions to be triggered based on IMAP actions like moving/copying. This cannot be accessed via sogo or user scripts, only mailcow's Global prefilter/postfilter. I can add further such scripts via dovecot's extra conf easily, but maybe a better way should exist.

My goal here is to start a discussion on this, as the developers of mailcow may have different ideas/opinions or may not consider this feature important at all.

For now, I could add a small few steps tutorial to the docs on how great sieve filtering can be achieved. For example, I have e-mails move to Archive/CompanyXY/YEAR/MONTH/ only AFTER I move them to Archive myself. This is very practical on a mobile phone, where I don't want to scroll through my archive to find where I want to move the e-mail. This feature cannot be activated from any existing interfaces but can be done without overwriting anything on mailcow's side via data/conf/dovecot/extra.conf:

plugin{
  imapsieve_mailbox4_name = Archive
  imapsieve_mailbox4_from = *
  imapsieve_mailbox4_causes = COPY
  imapsieve_mailbox4_before = file:/var/vmail/sieve/archive-sorter.sieve
}

Motivation

IMAPsieve is an awesome server-side mail automation tool but mailcow is missing out on it.

Additional context

Here is upsteam's documentation on this feature: https://doc.dovecot.org/configuration_manual/sieve/plugins/imapsieve/

Here is an example imapsieve filter:

if anyof (environment :is "imap.cause" "APPEND", environment :is "imap.cause" "COPY") {
        if environment :matches "imap.mailbox" "Archive" {
                set "targetfolder" "misc";
                if address :domain :contains "From" "steampowered.com" { set "targetfolder" "Steam"; }
                if address :domain :contains "From" "github.com" { set "targetfolder" "Github"; }
                if date :matches "received" "year" "*" { set "year" "${1}"; }
                if date :matches "received" "month" "*" { set "month" "${1}"; }
                addflag "\\Seen";
                fileinto :create "Archive/${targetfolder}/${year}/${month}";
        }
}
plantroon commented 1 year ago

I could upload managesieve filter through an external app and then set metadata for a folder via these IMAP commands: a SETMETADATA "Archive" (/shared/imapsieve/script "archive-sorter"

But is there an easier way?

Also, in extra.conf, imapsieve_url must be pointed to the server.