# Copyright (C) 2026 Ján Máté <jan.mate@inf-it.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.

This software resolves the issue of the Dovecot process locking up when integrated
with spam/ham reporting (the process waits for `sa-learn` to finish). This problem is
particularly severe during bulk message processing (e.g. thousands of messages).

The idea is simple:
  - When a message is reported as spam or ham, a copy of the message is created
    (in the specified cache directory) and the metadata required for further
    processing is written to the database (script /usr/local/bin/dovecot_spam_process)
  - A cron job then runs at regular intervals and executes `sa-learn` with the necessary
    arguments for each individual message (script /usr/local/bin/dovecot_spam_report)

Requirements:
  - Dovecot + Sieve :-)
  - Bash
  - PostgreSQL 17+ (at least the `psql` client to connect to the database)
  - SpamAssassin + Amavis (`sa-learn`)

Configuration (see the comments in the config file):
  - Config file: /usr/local/bin/dovecot_spam.conf
  - PostgreSQL schema: /usr/local/bin/dovecot_spam.sql

NOTE:
  - Relevant configuration fragments for Dovecot: /etc/dovecot/configuration_example.conf
  - This .tgz file contains the final disk layout for the files/directories
    (including the proper permissions and owner/group settings), except for the Dovecot
    configuration_example.conf above (it contains just the relevant fragments you need to
    integrate into your current configuration)
