Have rspamd autolearn, different names for spamboxes on server? Which to use?

Richard G

Verified User
Joined
Jul 6, 2008
Messages
14,994
Location
Maastricht
Just asking this to be sure. I've set up rspamd and now trying to let rspamd learn automatically.
I've seen a guide but that had a several comments so I'm using the instructions from the DA docs:
https://docs.directadmin.com/other-...omatically-marking-moved-mail-to-junk-as-spam

Now the question is about the middle part.
if environment :matches "imap.mailbox" "spam" {
and
if environment :matches "imap.mailbox" "Trash" {

Below there is a link:
Related: spam_inbox_prefix_name=INBOX.spam

In the docs I see "spam" and "ham" and in the sa-learn copy part there is "spam" again

If I check the DA mailboxes in webmail I see this:
1795915159274.png

So 2 different boxes called spam (1 with capital and one not) and a Trash folder.

When checking as root in the mailbox folders I see they all heb the INBOX prefix and one without and with a dot in front of the name and even one with a complete different name, like this.
.INBOX.spam
.INBOX.Trash
.Junk (this one I don't see in webmail)
.Trash

I'm not native English so this is very confusing to me. When following the docs, can I just copy and paste the instructions?
Or do I need to change everywhere where it says "spam" to .INBOX.spam or INBOX.spam without the dot in front?
And I don't have any "ham" folder which I read here:
pipe :copy "sa-learn.sh" [ "ham" ];

And what is the .Junk and .Trash then for which are not visible in webmail?
 
I've seen a guide but that had a several comments so I'm using the instructions from the DA docs:
https://docs.directadmin.com/other-...omatically-marking-moved-mail-to-junk-as-spam

The guide is for SpamAssassin, it won't work for rSpamd. See it says:

This guide describes the steps required to teach SpamAssassin

There was a guide for rSpamd on the forums somewhere. I don't have a link to it in my records, so you will need to find it on your own.

Anyway the only part that needs a change is the script: /usr/local/bin/dovecot-sieve/sa-learn.sh which is designed for SpamAssassin only. It won't do anything to rSpamd.

The other parts should work fine without changes.
 
Do not use the leading dot in the Sieve rules. That dot is Maildir’s on-disk directory syntax, not the IMAP mailbox name. So .INBOX.spam on disk is normally INBOX.spam to Dovecot, and .Junk is Junk.
Also, ham in sa-learn.sh [ "ham" ] is not a folder name. It is the learning mode passed to the classifier.
The bigger issue is that the linked DirectAdmin section currently says it is for SpamAssassin and its helper calls /usr/bin/sa-learn. Therefore I would not copy it unchanged for Rspamd. First confirm the logical mailbox names with doveadm mailbox list -u [email protected]; this also explains why .Trash and .INBOX.Trash can coexist, while Roundcube may only show subscribed folders.
DirectAdmin documents spam_inbox_prefix_name=INBOX.spam only when spam_inbox_prefix=1 is enabled. Pick one actual Junk mailbox name, use that consistently in the imapsieve rules, then connect the helper to Rspamd’s learner rather than assuming the shown sa-learn.sh applies.
DirectAdmin guide
 
There was a guide for rSpamd on the forums somewhere.
That might be this one:

Anyway the only part that needs a change is the script: /usr/local/bin/dovecot-sieve/sa-learn.sh
Does this relate to the original DA doc? If yes, then I might be able to use the orignal doc from da and just replace the sa-learn.sh by the rspamd-learn.sh script in part 4 of the guide here on the forums? Do I understand this correctly? Would make live a lot easier.

I've also seen some scripts on your github but that also says SA so I presume that only works for SA, right?

rather than assuming the shown sa-learn.sh applies.
DirectAdmin guide
Yes but zEitEr stated this was only for Spamassassin so I can't follow that guide.

The doveadm command shows me this output, without explanation.
Junk
Trash
Sent
Drafts
INBOX.Sent
INBOX.Drafts
INBOX.Trash
INBOX.spam
INBOX
So yes they co-exist but explain nothing. Stronger, it makes it more confusing to me. Junk folder does not exist in Roundcube, while Spam (with capital S) does, and that one does not exist here in the output, which confuses me about it's presense in Roundcube.

Edit: Just tested what is where a bit and something very odd happens. If I put a mail in the Spam (with begin capital) folder in Roundcube, then it will occur in the users .Junk/cur folder which is not visible so most likely not subsribed to in normal mail programs like Office Outlook, because that one only sees it when I move the mail to the "spam" folder in Roundcube, which in ssh is in fact the INBOX.spam folder.

Pick one actual Junk mailbox name, use that consistently in the imapsieve rules
I presume I have to pick one that is also visible in Roundcube too in that case. That would be INBOX.spam then as that is the only folder present both in the command output and in Roundcube and mail programs (test above), is that correct?
Or do I still misunderstand?

Sorry about all my questions, never been busy with mailboxes and all those different names just work confusing to me.
 
Last edited:
Yes but zEitEr stated this was only for Spamassassin so I can't follow that guide.

Anyway the only part that needs a change is the script: /usr/local/bin/dovecot-sieve/sa-learn.sh which is designed for SpamAssassin only. It won't do anything to rSpamd. The other steps should be OK
 
The other steps should be OK
Yes I've read that, which is why I asked this:
Does this relate to the original DA doc? If yes, then I might be able to use the orignal doc from da and just replace the sa-learn.sh by the rspamd-learn.sh script in part 4 of the guide here on the forums? Do I understand this correctly? Would make live a lot easier.
 
Yes, structurally that is the right idea, but I would not copy part 4 blindly.

Use the current DirectAdmin Dovecot 2.4 imapsieve section as the base, replace the SpamAssassin learner with an Rspamd-capable helper, and validate the resulting Dovecot config before restarting. The forum guide adds LMTP and controller-socket changes too; those are separate concerns and later replies in that thread flag problems, so I would not import the whole guide unchanged.

Your Roundcube test also answers the mailbox question: its displayed “Spam” folder maps to the logical IMAP mailbox “Junk” (stored on disk as .Junk). “INBOX.spam” is a different mailbox, shown as the lower-case spam folder. If users move mail into Roundcube’s Spam folder, the imapsieve trigger should therefore use “Junk”, not “INBOX.spam”. Subscribe Junk in Outlook/other clients if you want every client to use that same folder, rather than training two duplicate folders.

And yes, “spam” and “ham” passed to the helper are learning actions, not mailbox names.

DirectAdmin reference: https://docs.directadmin.com/other-...omatically-marking-moved-mail-to-junk-as-spam
 
If users move mail into Roundcube’s Spam folder
Ah like that it works.
However at least Outlook programs (also on my phone) does not see that "Junk" folder, same as my outlook on my Android phone. It's hard to teach customers they have to subscribe to some folder they don't even see.
Funny enough Thunderbird -does- see that by default, however TB also sees that "spam" folder in the inbox.

It would be great if we could hide that INBOX.spam (so that "spam") folder someway.
If it's already confusing to me, for sure it is confusing to customers and I'm very sure they will also start putting spam in the wrong spam folder for that reason.
I see in Dovecot's namespace_private.conf all 3 names, Junk, spam and Spam, all set to non autosubscribe. So no clue as to why Outlook chooses to automatically subscribe to the "spam" and not any of the others.

And yes, “spam” and “ham” passed to the helper are learning actions, not mailbox names.
That makes at least that part clear to me. I thought I had to replace "spam" in there with the spam mailbox used.
 
Back
Top