# Spam not learned when moving to spam folder

**URL:** <https://discourse.mailinabox.email/t/spam-not-learned-when-moving-to-spam-folder/12206>\
**Category:** Help with Unusual Circumstances\
**Created:** [August 6, 2024, 7:23am UTC](https://discourse.mailinabox.email/t/spam-not-learned-when-moving-to-spam-folder/12206 "2024-08-06T07:23:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![robertpopa22](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/robertpopa22/32/2110_2.png) [@robertpopa22](https://discourse.mailinabox.email/u/robertpopa22)\
**Post date:** [August 6, 2024, 7:23am UTC](https://discourse.mailinabox.email/t/spam-not-learned-when-moving-to-spam-folder/12206/1 "2024-08-06T07:23:16Z")

</div>

I have MaiB for several years. Now everything is upgraded to the latest versions.

I noticed in the past months that learning was not ok. When I checked the  
sudo sa-learn --dump magic  
I could not find any change when I moved an email to the spam folder…

Any idea on what may be wrong? Or what and how should I check the filters?

---

<div class="post-metadata">

**Author:** ![LesGrossman](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/l/a698b9/32.png) [@LesGrossman](https://discourse.mailinabox.email/u/LesGrossman)\
**Post date:** [August 8, 2024, 1:30pm UTC](https://discourse.mailinabox.email/t/spam-not-learned-when-moving-to-spam-folder/12206/2 "2024-08-08T13:30:41Z")

</div>

I really like MIAB, but Spam Handling is an absolute Pain.  
I´ve ended up creating my own filter with a Sieve file.

In the Folder /etc/dovecot I´ve created the file “sieve-spam.sieve” with this code - works like a charm.

```auto
require ["regex", "fileinto", "imap4flags", "reject", "body", "mailbox"];

if address :domain :matches "from" ["*fisteraser.de", "*freenet-mobilfunk.de", "*.br", "*.tr", "*.xyz", "*.jp", "*.ro", "*.click", "*.pl", "*.cn", "*.tk", "*.buzz", "*.top", "*.ga", "*.cf", "*.gq", "*.icu", "*.wang", "*.host", "*.ir", "*.mg", "*.au", "*.ca", "*.ltd", "*.pro", "*.ru", "*.mx", "*.id"]
    {
        reject "REJECTED";
	    stop;

    }

if header :contains "from" ["huusk", "tfbank", "servicekarte", "doktor", "freenet", "fisteraser", "comdirect", "lidl", "wholesale", "emura"]
    {
        reject "REJECTED";
	    stop;

    }

if header :contains "subject" ["info ", "spende", "invest", "info,", "$user_name$", "keto", "wachstum", "geld", "bersetz", " KI ", "prosta", "reich", "schuppe", "schlank", "dividend", "messer der welt", "apotheke", "sex"]
    {
        reject "REJECTED";
	    stop;

    }

#if body :content "text" :contains ["finds you well", "%User_Name%", "keto", "Achtung, info!", "finanzielle Probleme", "manneskraft", "antibiotika", "prostat", "stehkraft", "liebesleben", "wie es frueher noch der fall war", "schuppen", "erektion", "arznei", "diskret in den briefkasten", "appetit", "apotheke", "fitnes", "sex", "schmerzen", "unbehagen"]
# {
# #reject "REJECTED"
# fileinto :create "Body Test";
# stop;
# }

```

---

<div class="post-metadata">

**Author:** ![ben7230](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/b/a587f6/32.png) [@ben7230](https://discourse.mailinabox.email/u/ben7230)\
**Post date:** [September 11, 2025, 2:39am UTC](https://discourse.mailinabox.email/t/spam-not-learned-when-moving-to-spam-folder/12206/3 "2025-09-11T02:39:34Z")

</div>

I have been trying to create a simple reject filter but it doesn’t seem to work.

```auto
require "reject";
# rule Encuentra24
if address :domain :matches "from" "encuentra24.com"
{
        reject "REJECTED";
        stop;
}

```

What am i doing wrong? I have been testing this by sending emails from my work email and putting my work domain into the filter, but its not working.

Do I need to restart a service on the server?

---

<div class="post-metadata">

**Author:** ![KiekerJan](https://discourse.mailinabox.email/user_avatar/discourse.mailinabox.email/kiekerjan/32/2339_2.png) [@KiekerJan](https://discourse.mailinabox.email/u/KiekerJan)\
**Post date:** [September 11, 2025, 4:41pm UTC](https://discourse.mailinabox.email/t/spam-not-learned-when-moving-to-spam-folder/12206/4 "2025-09-11T16:41:43Z")

</div>

I’m not sure if you need to reload dovecot if you create files like this.  
However, perhaps it is easier to use the sieve filter editor that is built-in into Roundcube, the webmail UI?

---

<div class="post-metadata">

**Author:** ![ben7230](https://discourse.mailinabox.email/letter_avatar_proxy/v4/letter/b/a587f6/32.png) [@ben7230](https://discourse.mailinabox.email/u/ben7230)\
**Post date:** [September 14, 2025, 2:01am UTC](https://discourse.mailinabox.email/t/spam-not-learned-when-moving-to-spam-folder/12206/5 "2025-09-14T02:01:15Z")

</div>

Ok, so I had more than one rule and I was using “require” for each rule. Thanks to ChatGPT, it immediately pointed that out.

After fixing that, its working good.
