-1

I try to filter mails by subaddress :detail parts in sieve scripts.

Goal is the usage of regex patterns as in this simple test case:

if envelope :detail :regex "to" ["^test$"]{                                                                                                             
  fileinto "Social";
  stop;
}
if envelope :detail ["to"] ["test"]{
  fileinto "Social";
  stop;
}

Neither of both scripts work.

If I enable trace in my dovecot configuration, I can see, that the address, sieve tries to extract the detail from doesn't contain the detail part any more, while the "to"-header used for a header test in the same script does.

12: header test
12:   starting `:regex' match with `i;ascii-casemap' comparator:
12:   extracting `to' headers from message
12:   matching value `"user+test@domain.net" <user+test@domain.net>'
12:     with regex `.*blogs' [id=0] => 0
12:   finishing match with result: not matched
12: jump if result is false
12:   jumping to line 18
18: envelope test
18:   starting `:regex' match with `i;ascii-casemap' comparator:
18:   getting `to' part from message envelope
18:   extracting `detail' part from address `user@domain.net'
18:   finishing match with result: not matched
18: jump if result is false
18:   jumping to line 22
22: envelope test
22:   starting `:is' match with `i;ascii-casemap' comparator:
22:   getting `to' part from message envelope
22:   extracting `detail' part from address `user@domain.net'
22:   finishing match with result: not matched
22: jump if result is false
22:   jumping to line 32

So, what could be reasons for dovecot to cut down the detail part for envelope?

Michael Ef
  • 1
  • 1
  • 5

1 Answers1

0

Well, serverfaults related question suggestions finally got me on the right track.

As suggested in this solution, the problem is not dovecot or sieve, it is postfix. So I changed the following line in my postfix master.cf to submit not only user and domain, but also the original recipient address.

# old
dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}
# new
dovecot   unix  -       n       n       -       -       pipe
  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop} -a ${original_recipient}
Michael Ef
  • 1
  • 1
  • 5