There seem to be two issues in the Mail-in-a-Box setup scripts that prevent the spam filters from learning when
emails are moved to the "Junk" folder.
Issue 1: Multiple mail_plugins lines in 20-imap.conf cause overrides.
In setup/mail-dovecot.sh, the logic for adding the imap_quota plugin to the protocol imap block in
/etc/dovecot/conf.d/20-imap.conf adds a second mail_plugins line instead of appending to the existing one. Because
Dovecot uses the last occurrence of a setting within a block, this effectively disables any other plugins (like
antispam) that were previously configured.
- Affected Code (setup/mail-dovecot.sh):
if ! grep -q "mail_plugins.* imap_quota" /etc/dovecot/conf.d/20-imap.conf; then
sed -i "s/\(mail_plugins =.*\)/\1\n mail_plugins = \$mail_plugins imap_quota/"
/etc/dovecot/conf.d/20-imap.conf
fi
- Proposed Fix:
Change the sed command to append to the existing line:
sed -i "s/\(mail_plugins =.*\)/\1 imap_quota/" /etc/dovecot/conf.d/20-imap.conf
Issue 2: antispam plugin ignores folders named 'Junk'.
Mail-in-a-Box configures Dovecot to provide both "Spam" and "Junk" folders (via 15-mailboxes.conf), but the antispam
plugin is only configured to watch folders matching the pattern SPAM. When a client moves mail into a folder named
"Junk" (which is common for many IMAP clients), the learning script is never triggered.
-
Affected Code (setup/spamassassin.sh):
antispam_spam_pattern_ignorecase = SPAM
-
Proposed Fix:
Update the pattern to include both common names:
antispam_spam_pattern_ignorecase = SPAM;Junk
Impact:
Users who move emails to the "Junk" folder (instead of "Spam") will find that their spam filters never improve, as the
sa-learn process is skipped entirely. Additionally, for most IMAP users, the antispam plugin is currently disabled by
the imap_quota configuration.
There seem to be two issues in the Mail-in-a-Box setup scripts that prevent the spam filters from learning when
emails are moved to the "Junk" folder.
Issue 1: Multiple mail_plugins lines in 20-imap.conf cause overrides.
In setup/mail-dovecot.sh, the logic for adding the imap_quota plugin to the protocol imap block in
/etc/dovecot/conf.d/20-imap.conf adds a second mail_plugins line instead of appending to the existing one. Because
Dovecot uses the last occurrence of a setting within a block, this effectively disables any other plugins (like
antispam) that were previously configured.
Change the sed command to append to the existing line:
sed -i "s/\(mail_plugins =.*\)/\1 imap_quota/" /etc/dovecot/conf.d/20-imap.confIssue 2: antispam plugin ignores folders named 'Junk'.
Mail-in-a-Box configures Dovecot to provide both "Spam" and "Junk" folders (via 15-mailboxes.conf), but the antispam
plugin is only configured to watch folders matching the pattern SPAM. When a client moves mail into a folder named
"Junk" (which is common for many IMAP clients), the learning script is never triggered.
Affected Code (setup/spamassassin.sh):
antispam_spam_pattern_ignorecase = SPAMProposed Fix:
Update the pattern to include both common names:
antispam_spam_pattern_ignorecase = SPAM;JunkImpact:
Users who move emails to the "Junk" folder (instead of "Spam") will find that their spam filters never improve, as the
sa-learn process is skipped entirely. Additionally, for most IMAP users, the antispam plugin is currently disabled by
the imap_quota configuration.