From 10d675e8a545afeaea009d37028dc9bc4221af1c Mon Sep 17 00:00:00 2001 From: Mauro Torrez Date: Sun, 7 Aug 2022 18:19:52 -0300 Subject: [PATCH] add antispam support using imap sieve --- 15-mailboxes.conf | 44 ------ 90-antispam.conf | 50 ------- 90-sieve.conf | 214 ----------------------------- Dockerfile | 106 +++++++------- confd/conf.d/imap.toml | 1 + confd/conf.d/lmtp.toml | 4 +- confd/conf.d/sieve.toml | 7 + confd/conf.d/ssl.toml | 1 + confd/templates/10-auth.conf.tmpl | 2 +- confd/templates/10-ssl.conf.tmpl | 48 +------ confd/templates/20-imap.conf.tmpl | 2 +- confd/templates/20-lmtp.conf.tmpl | 4 +- confd/templates/90-sieve.conf.tmpl | 22 +++ report-ham.sieve | 15 ++ report-spam.sieve | 7 + sievec | 6 + spamtrain => spamtrain.sh | 5 +- 17 files changed, 120 insertions(+), 418 deletions(-) delete mode 100644 90-antispam.conf delete mode 100644 90-sieve.conf create mode 100644 confd/conf.d/sieve.toml create mode 100644 confd/templates/90-sieve.conf.tmpl create mode 100644 report-ham.sieve create mode 100644 report-spam.sieve create mode 100755 sievec rename spamtrain => spamtrain.sh (78%) diff --git a/15-mailboxes.conf b/15-mailboxes.conf index 1a5ac41..43729da 100644 --- a/15-mailboxes.conf +++ b/15-mailboxes.conf @@ -1,47 +1,3 @@ -## -## Mailbox definitions -## - -# Each mailbox is specified in a separate mailbox section. The section name -# specifies the mailbox name. If it has spaces, you can put the name -# "in quotes". These sections can contain the following mailbox settings: -# -# auto: -# Indicates whether the mailbox with this name is automatically created -# implicitly when it is first accessed. The user can also be automatically -# subscribed to the mailbox after creation. The following values are -# defined for this setting: -# -# no - Never created automatically. -# create - Automatically created, but no automatic subscription. -# subscribe - Automatically created and subscribed. -# -# special_use: -# A space-separated list of SPECIAL-USE flags (RFC 6154) to use for the -# mailbox. There are no validity checks, so you could specify anything -# you want in here, but it's not a good idea to use flags other than the -# standard ones specified in the RFC: -# -# \All - This (virtual) mailbox presents all messages in the -# user's message store. -# \Archive - This mailbox is used to archive messages. -# \Drafts - This mailbox is used to hold draft messages. -# \Flagged - This (virtual) mailbox presents all messages in the -# user's message store marked with the IMAP \Flagged flag. -# \Junk - This mailbox is where messages deemed to be junk mail -# are held. -# \Sent - This mailbox is used to hold copies of messages that -# have been sent. -# \Trash - This mailbox is used to hold messages that have been -# deleted. -# -# comment: -# Defines a default comment or note associated with the mailbox. This -# value is accessible through the IMAP METADATA mailbox entries -# "/shared/comment" and "/private/comment". Users with sufficient -# privileges can override the default value for entries with a custom -# value. - # NOTE: Assumes "namespace inbox" has been defined in 10-mail.conf. namespace inbox { # These mailboxes are widely used and could perhaps be created automatically: diff --git a/90-antispam.conf b/90-antispam.conf deleted file mode 100644 index e6223f9..0000000 --- a/90-antispam.conf +++ /dev/null @@ -1,50 +0,0 @@ -plugin { - -# antispam_debug_target = syslog -# antispam_debug_target = stderr -# antispam_verbose_debug = 1 - -antispam_backend = pipe - -# mail signature (used with any backend requiring a signature) -antispam_signature = X-Bogosity - -# antispam_signature_missing = move # move silently without training -antispam_signature_missing = error - -# semicolon-separated list of Trash folders (default unset i.e. none) -# antispam_trash = -# antispam_trash = trash;Trash;Deleted Items; Deleted Messages -# antispam_trash_pattern = trash;Trash;Deleted * -# antispam_trash_pattern_ignorecase =trash;deleted * -antispam_trash = Trash;trash;mail/trash;Deleted Messages - -# semicolon-separated list of spam folders -# antispam_spam = SPAM -# antispam_spam_pattern = SPAM -# antispam_spam_pattern_ignorecase = junk*;spam* -antispam_spam = Junk;junk;Junk Mail;Spam;spam;SPAM - -# semicolon-separated list of unsure folders (default unset i.e. none) -# antispam_unsure = -# antispam_unsure_pattern = -# antispam_unsure_pattern_ignorecase = - -# Whether to allow APPENDing to SPAM folders or not -# antispam_allow_append_to_spam = no - -#===================== -# pipe plugin - -# temporary directory -antispam_pipe_tmpdir = /tmp - -# spam/not-spam argument (default unset which will is not what you want) -antispam_pipe_program_spam_arg = spam -antispam_pipe_program_notspam_arg = ham - -# binary to pipe mail to -antispam_pipe_program = /usr/local/bin/spamtrain -#antispam_pipe_program_args = -f;%u@example.com # % expansion done by dovecot - -} diff --git a/90-sieve.conf b/90-sieve.conf deleted file mode 100644 index 12af1c9..0000000 --- a/90-sieve.conf +++ /dev/null @@ -1,214 +0,0 @@ -## -## Settings for the Sieve interpreter -## - -# Do not forget to enable the Sieve plugin in 15-lda.conf and 20-lmtp.conf -# by adding it to the respective mail_plugins= settings. - -# The Sieve interpreter can retrieve Sieve scripts from several types of -# locations. The default `file' location type is a local filesystem path -# pointing to a Sieve script file or a directory containing multiple Sieve -# script files. More complex setups can use other location types such as -# `ldap' or `dict' to fetch Sieve scripts from remote databases. -# -# All settings that specify the location of one ore more Sieve scripts accept -# the following syntax: -# -# location = [:]path[;