Moving Spam emails to Spam folder Using RoundCube and Dovecot-Pigeonhole

OS: Rocky Linux 9.2
Services: Dovecot, Dovecot-Pigeonhole, Postfix, Spamassassin, RoundCube

I’m trying to move emails flagged as spam by Postfix and Spamassassin to the spam folder using Dovecot-Pigeonhole and RoundCube, I made these steps and the filters tab has been shown at RoundCube but the flagged emails are still in the inbox.

P.S. I don’t know which action is correct. Add post 4190 in Inbound Rules and block it using Firewalld or, don’t add it in Inbound Rules?

— Dovecot —

# ------------- 15-lda.conf -------------
# Should saving a mail to a nonexistent mailbox automatically create it?
lda_mailbox_autocreate = yes

# Should automatically created mailboxes be also automatically subscribed?
lda_mailbox_autosubscribe = yes

protocol lda {
  # Space separated list of plugins to load (default is global mail_plugins).
  mail_plugins = $mail_plugins autocreate sieve quota
}

# ------------- 20-lmtp.conf -------------
protocol lmtp {
  # Space separated list of plugins to load (default is global mail_plugins).
  mail_plugins = $mail_plugins autocreate sieve quota
}

# ------------- 20-managesieve.conf -------------
# Uncomment to enable managesieve protocol:
protocols = $protocols sieve

# Service definitions
service managesieve-login {
  inet_listener sieve {
    port = 4190
  }
}

# Service configuration
protocol sieve {
  managesieve_max_line_length = 65536
  managesieve_implementation_string = Dovecot Pigeonhole
}

# ------------- 90-sieve.conf -------------
plugin {

  # Default line after installing Dovecot-Pigeonhole
  sieve = file:~/sieve;active=~/.dovecot.sieve

  # This is Mine
  sieve_default = /etc/dovecot/sieve/default.sieve
}

Now, I have created /etc/dovecot/sieve directory and /etc/dovecot/sieve/default.sieve file inside with the following code:

require ["envelope", "fileinto", "mailbox"];
# rule:[Filtering Spam]
if header :contains "X-Spam-Flag" "YES"
{
    fileinto "Spam";
    stop;
}

I always reading about that directory /etc/roundcube/ but I didn’t find it in my system and I know that I can’t edit the RoundCube config file from the installed directory because it’ll be replaced every upgrade, So it’s temporarily until I figured it out, So if anyone can help to create RoundCube settings on /etc/roundcube/ will be great

I have installed RoundCube on a subdomain and modified the SUBDOMAIN/public_html/config/config.inc.php

$config['plugins'] = [
    'archive',
    'zipdownload',

    // This is mine
    'managesieve'
];


$config['managesieve_host'] = 'localhost';
$config['managesieve_default'] = '/etc/dovecot/sieve/default.sieve';

Now, I got a Filters tab on my RoundCube, But unfortunately, RoundCube is unable to create a Spam folder automatically, and even if I create it manually, The Flagged emails don’t move into it.

Screenshots of the result I have got

- Filters Tab has been shown in the RoundCube

- RoundCube doesn’t move the SPAM emails to Spam folder and not even create a Spam folder.

If you using Virtualmin this should already happen. What system are you using.

I hope so :slight_smile: I think I have to configure it because it’s not happening by default.

OS: Rocky Linux 9.2
Virtualmin: 7.7

Virtualmin will give you the option of dumping emails identified as spam into a spam folder. You don’t need to create that folder or do any of the sieve stuff I saw in your post.


Then, in Roundcube, you will see emails in that spam folder. When you find an email that is Spam but not identified, you drag it manually into the spam folder. The next step is to use a script that calls sa-learn (spamassassin learning) that will learn from your specific spam and gradually it get better results. This is called bayes learning in SA lingo. The SpamAssassin libraries for new spam detection are updated nightly using a cron job and that should be automatically setup when you run Virtualmin.

My script runs nightly, learns from my spam folder then I delete any spam emails from the spam folder after 10 days. That give me enough time to detect non-spam emails that were wrongly identified. There is a ton of SA material on the web, you will find lots of help with research but the scripts are already done and available to copy for your installation.

1 Like

Many Thanks, bro,

My bad, I always disable Spam and Virus plugins to reduce memory usage, My server is 4 GB and 2.30 GB Used.

I’m trying to fix this with Sieve to get this experience in administration instead of GUI but it seems like no one can help in three forums no answer :slight_smile:

Thanks again, I will try it and watch memory usage.

Just disable disable virus. I have 4GIG system and it runs fine.

I’ve always disabled clam anti virus but retained spamassassin. The anti virus will consume all cpu I’ve found and is of no use in my experience. Spamassassin (spamd) and f2b use limited resources and work silently on small servers.

2gb real memory used in 4GB server using Virtualmin with a bunch of domains. Active with f2b and SA but no ClamAV. ClamAV stops this server dead. Here is what is running.

Here are the server stats and there is no load from SA or F2B

1 Like

You can remove it in features and plugins, also do you need that many php version?

1 Like

@stefan1959 @paulM
Thanks a lot, guys, I will do it.

But really need to learn more about Dovecot Sieve :slight_smile:

Thanks

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.