This shows you the differences between two versions of the page.
| — | fuss:spamassassin [2025/10/21 23:26] (current) – created - external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Scanning User Mailboxes for Spam and Training the Bayes Filter ====== | ||
| + | |||
| + | The script below requires a mail transfer agent such as Dovcot that is set up to place mailboxes under the user's home directories in ''/ | ||
| + | |||
| + | <file bash sa-learn-junk-folders.sh> | ||
| + | #!/bin/sh | ||
| + | ########################################################################### | ||
| + | ## Copyright (C) Wizardry and Steamworks 2017 - License: GNU GPLv3 ## | ||
| + | ########################################################################### | ||
| + | # A script to make amavis / spamassassin learn spam mail through bayes # | ||
| + | # from all the mailboxes present on the system. | ||
| + | # # | ||
| + | # For this script to work, a mail-server must be configured by enabling | ||
| + | # IMAP mailboxes stored in the user's home directory, users should have a # | ||
| + | # virtual mailbox " | ||
| + | # After that, you can configure the script and reference it in crontab. | ||
| + | ########################################################################### | ||
| + | |||
| + | ########################################################################### | ||
| + | # | ||
| + | ########################################################################### | ||
| + | |||
| + | # The name of the Junk folder - under Dovecot, this is commonly " | ||
| + | JUNK_FOLDER=" | ||
| + | # The path to the spamassassin database. | ||
| + | SPAMASSASSIN_DATABASE="/ | ||
| + | # The mailbox type can be either: Maildir, mail or sdbox | ||
| + | MAILBOX_TYPE=" | ||
| + | |||
| + | ########################################################################### | ||
| + | #                                INTERNALS | ||
| + | ########################################################################### | ||
| + | |||
| + | # Train spam from junk folder. | ||
| + | for i in `find / | ||
| + | HOME_FOLDER=`echo $i | awk -F"/" | ||
| + | sa-learn --use-ignores \ | ||
| + | --dbpath " | ||
| + | -p "/ | ||
| + | --spam " | ||
| + | done | ||
| + | |||
| + | # Sync databases | ||
| + | sa-learn --dbpath " | ||
| + | |||
| + | </ | ||
For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.