Dovecot: How can I prevent sieve filter from being applied to some mail users?

We have an [email protected] mailbox that receives orders from customers. Postfix redirects such emails to the email addresses of our sales managers, as well as to the special address [email protected], which is used by some analytical software. For this, a file named "Virtual" has been created in the Postfix folder with the following contents:

[email protected]   [email protected],[email protected],[email protected],[email protected]

In addition, Dovecot places all such emails in the Orders folder of each sales manager. For this, a Sieve filter rule has been created:

require ["fileinto", "envelope"];
if envelope: is "to" "[email protected]" {
  fileinto "Orders";
  stop;
}

But the problem is that the analytics software that uses the [email protected] mailbox is subscribed only to the default Inbox folder. And it doesn't know how to work with the Orders folder. So I need to somehow prevent the filter from being applied to the [email protected] mailbox. How can I do this using Dovecot or Sieve?


Solution 1:

In my case, the problem was solved using the "Delivered-To" header:

require ["fileinto", "envelope"];

if allof (envelope :is "to" "[email protected]",
        not header :is "Delivered-To" "[email protected]")
{
  fileinto "Orders";
  stop;
}