On 9/6/2026 9:48 PM, Jorge Bastos via dovecot wrote:
    Hi all,

    Well, my issue is not exacly what you descrived,

    I have an account, that i want to forward all incoming emails, so far so
    good.
    Before the emails are forward, i want to delete some, based on the sender
    domain.

    Thing is, i think managesieve roundcube plugin is producing the script
    wrong, here's what i have, i have 1 rule for the delete some senders, ok,
    and the 2nd for the redirect

    # rule:[blocks]
    if anyof (header :contains "from" "clubefashion.com", header :contains
    "from" "nutribody.pt", header :contains "from" "mcdonalds.pt")
    {
    discard;
    redirect "[email protected]";
    }
    # rule:[redir]
    if true
    {
    redirect "[email protected]";
    }


Hello,

if you want to forward all of the emails, regardless of the sender domain and then "delete" them from the original inbox I would do (option 1):

   # rule:[blocks]
if anyof (header :contains "from" "clubefashion.com", header :contains "from" "nutribody.pt", header :contains "from" "mcdonalds.pt")
   {
   redirect "[email protected]";
   discard;
   stop;
   }
   # rule:[redir]
   if true
   {
   redirect "[email protected]";
   stop;
   }

If, on the other hand you do not want do forward them and also do not want to keep them then simply do (option 2):

   # rule:[blocks]
if anyof (header :contains "from" "clubefashion.com", header :contains "from" "nutribody.pt", header :contains "from" "mcdonalds.pt")
   {
   discard;
   stop;
   }
   # rule:[redir]
   if true
   {
   redirect "[email protected]";
   stop;
   }

option 1 - Email is redirected, discarded and rule processing stops (which inhibits the implicit "keep" from running, so the email is redirected to the other mailbox but not kept on the original one).

option 2 - Email from those domains is discarded and rule processing stops, again inhibiting the implicit keep. For the other domains, email is redirected and "implicilty" kept on the original mailbox.

if you're using roundcube you should have an action when creating the rule to "stop evaluating rules" or something else to that effect when creating the rule, that will add the "stop;" line on each rule.
you just need to add it in the correct order to make it work.

In your first message you stated that you wanted to avoid having those blocked domain emails from being stored in the original mailbox, so option 2 should work correctly for that. The rules you have in this message will redirect both the "blocked" and all other emails to being redirected to the other mailbox, which is what option 1 gives you. With the rules you sent you would get *two* emails from the "blocked" domains being redirected to "[email protected]" since both rules would match.

Hope this clarifies and helps you achieve the desired outcome. Both are entirely possible with roundcube generated sieve rules, you just need to decide on which of the two you want.

Regards,

    On 2026-09-06 10:15, Toth Attila via dovecot wrote:

      I'm using a filter that moves the mail to another directory. The
      original message disappeared only from the initial location if
      imapsieve_expunge_discarded = yes was set. A duplicate remained
      otherwise. I suggest to take a look at on this configuration option
      depending on the purpose of the filter.

      On 2026.09.06 02:30, Stephan Bosch via dovecot wrote:

        Op 2-9-2026 om 16:00 schreef Antonio Oliveira via dovecot:

          Hello,

          You can try to add "stop;" after "discard;", so that rule processing
          stops after the discard and doesn't trickle down to the other rule.

        Yes, this will help. Why? The discard action command only cancels the
        implicit keep; nothing else. It means that if and only if no other
        explicit action delivers or preserves (keeps!) the message somehow, it
        is discarded. So, if subsequently redirect is triggered, the message
        is redirected, thereby making the discard action ineffective. Stopping
        the script right after discard will make sure no other actions can be
        triggered, thereby making sure the message is discarded (provided no
        earlier actions already triggered some sort of delivery either).
        Without discard or any other action command that cancels the implicit
        keep (such as redirect, fileinto, and ... keep), the default action is
        to "keep" the message, e.g. file it to INBOX.

        Regards,

        Stephan.

          On 9/2/2026 1:05 PM, Jorge Bastos via dovecot wrote:

                Hi guys,

                Small help with a sieve script, I have the script below in a
            useraccount,
                in this exact order.
                The redirect works, but the discard doesn't.
                A message that comes from the domain "clubefashing.com" or
            "nutribody.pt",
                is always redirected.

                Any idea what is wrong here?

                # rule:[blocks]
                if anyof (header :contains "from" "clubefashion.com", header
            :contains
                "from" "nutribody.pt")
                {
                discard;
                }
                # rule:[redir]
                if true
                {
                redirect "[1][email protected]";
                }

            _______________________________________________
            dovecot mailing list -- [2][email protected]
            To unsubscribe send an email to [3][email protected]

        _______________________________________________
        dovecot mailing list -- [4][email protected]
        To unsubscribe send an email to [5][email protected]

References

    Visible links
    1. mailto:[email protected]
    2. mailto:[email protected]
    3. mailto:[email protected]
    4. mailto:[email protected]
    5. mailto:[email protected]


_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

--
Anto'nio Henrique A. Proenca de Oliveira
"Although we can never go back, like an old sweet
song with a strong refrain, memories remain" - (Someone)

Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html
$Id: .signature,v 1.5 2008/03/13 11:22:00 tat Exp tat $

_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to