Sieve_before

at lbutlr at lbutlr
Fri Oct 23 18:54:54 EEST 2020


On 23 Oct 2020, at 05:47, @lbutlr <kremels at kreme.com> wrote:
> Excellent! That was the secret sauce!
> 
> Thank you!

For the sake of completeness, this is what I have ended up with:

#v+
require ["copy", "variables", "envelope", "fileinto", "subaddress"];
   # :matches has implicit ^ and $ around the match
   if not envelope :matches "to" "*backup*" {
    # get the top level after @ (example.com => example)
    if envelope :matches "to" "*@*.*" {
        set :lower "domn" "${2}";
    }
    # get the user without detail (foo+bar => foo)
    if envelope :user :matches "to" "*" {
       set :lower "user" "${1}";
    }
    # Un-needed step, but shows what is done in the trace log
    set "backup" "backup+297.${domn}.${user}@*somedomain*";
    redirect :copy "${backup}";
   }
#v-

(I don't think I need fileinto)

This means that mail for user at domain.tld and user+foo at domain.tld ends up in a mailbox, today, of

backup/Maildir/.297.domain.user/

And user2 at domain.tld

backup/Maildir/.297.domain.user2/

(Which means the backup IMAP hierarchy is all sorted DOY=>domain=>user)

I'd like a fail condition if the redirect for some reason cannot send, but that's a project for tomorrow.

-- 
and I swear it happened just like this: / a sigh, a cry, a hungry
	kiss, the Gates of Love they budged an inch / I can't say much
	has happened since / but CLOSING TIME



More information about the dovecot mailing list