Antonio,

   Oh, i'm so sorry for the question and the time of you all.
   Yes, i'm missing the stop on the 1st rule, sieve executes them from top to
   bottom.

   Solved, and thank you all for the time,

   On 2026-09-06 22:14, Antonio Oliveira via dovecot wrote:

     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 "[1][email protected]";
           }
           # rule:[redir]
           if true
           {
           redirect "[2][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 "[3][email protected]";
        discard;
        stop;
        }
        # rule:[redir]
        if true
        {
        redirect "[4][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 "[5][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 "[6][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][7][email protected]";
                       }

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

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

       References

           Visible links
           1. mailto:[12][email protected]
           2. mailto:[13][email protected]
           3. mailto:[14][email protected]
           4. mailto:[15][email protected]
           5. mailto:[16][email protected]

       _______________________________________________
       dovecot mailing list -- [17][email protected]
       To unsubscribe send an email to [18][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]
   6. mailto:[email protected]
   7. mailto:[email protected]
   8. mailto:[email protected]
   9. mailto:[email protected]
  10. mailto:[email protected]
  11. mailto:[email protected]
  12. mailto:[email protected]
  13. mailto:[email protected]
  14. mailto:[email protected]
  15. mailto:[email protected]
  16. mailto:[email protected]
  17. mailto:[email protected]
  18. mailto:[email protected]
_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to