Hi,
I ran into the same issue while researching this topic, and I was able to fix it with the following configuration.
Hopefully this helps someone else facing the same problem.
When upgrading to
Dovecot 2.4, many administrators discovered that the traditional plugin { sieve_after = ... } configuration stopped working.
This is due to structural changes introduced in Dovecot 2.4, where
plugin blocks are no longer used and
Sieve scripts must be declared as script storages instead.
This article describes how to correctly implement a
global Sieve filter in Dovecot 2.4, using a Plesk-managed environment as an example.
Prior to Dovecot 2.4, global Sieve rules were usually configured through:
plugin {
sieve_after = /etc/dovecot/sieve/global_after.sieve
}
After upgrading to version 2.4, this configuration fails with:
Fatal: Error in configuration file: Unknown section name: plugin
That’s because all plugin configuration keys are now defined directly at the top level (global context), rather than inside a plugin {} block.
Sieve scripts also now use the sieve_script declaration format.
Step-by-Step Configuration
1. Create a global configuration file
Create a new configuration file under /etc/dovecot/conf.d/
(you can name it 54-sieve-global.conf or similar to load it after core configs):
nano /etc/dovecot/conf.d/54-sieve-global.conf
# Global Sieve configuration (Dovecot 2.4+)
# Vizra.com Global SPAM to JUNK
# Executes after user-defined Sieve filters
sieve_script global_after {
path = /etc/dovecot/sieve/global_after.sieve
type = after
}
2. Create the Sieve script
mkdir -p /etc/dovecot/sieve
nano /etc/dovecot/sieve/global_after.sieve
Paste the following content:
require ["fileinto"];
# Vizra SPAM to JUNK
if allof (header :contains "Subject" "***SPAM***") {
fileinto "INBOX.Spam";
stop;
}
This rule automatically moves any email with "
SPAM" in the subject line to the user’s Spam folder (INBOX.Spam).
3. Compile the Sieve script
Dovecot requires Sieve scripts to be compiled into a binary form before use:
sievec /etc/dovecot/sieve/global_after.sieve
You should now see both files in /etc/dovecot/sieve/:
global_after.sieve
global_after.svbin
4. Restart Dovecot
Reload Dovecot to apply the configuration:
systemctl restart dovecot
5. Send a test email
To verify the rule, send yourself a test message:
echo -e "Subject: ***SPAM*** Test Mail\n\nThis is a test message." | sendmail
[email protected]
Then check the mailbox (or Maildir folder).
You should find the message stored in INBOX.Spam.