Topic: ANTISPAM via Dovecot and Spamassassin
==== Required information ====
- iRedMail version: 0.8.7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Linux/BSD distribution name and version: Debian 7
====
I have a user based AntiSpam made for Dovecot with Spamassassin.
1. Install via apt-get:
apt-get install dovecot-antispam
2. Mod, Add Dovecot Settings:
protocol imap {
...
mail_plugins = $mail_plugins antispam
}
plugin {
...
#antispam_debug_target = syslog
#antispam_verbose_debug = 1
antispam_backend = pipe
antispam_trash = Trash
antispam_spam = Junk
antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg = --ham
antispam_pipe_program = /usr/bin/sa-learn
antispam_pipe_program_args = --username=%Lu
}
3. Edit the local.cf from spamassassin: (NOTICE: Write down the "Data you Setting for MYSQL connection")
use_bayes 1
bayes_auto_learn 1
bayes_auto_expire 1
# Store bayesian data in MySQL
bayes_store_module Mail::SpamAssassin::BayesStore::MySQL
bayes_sql_dsn DBI:mysql:(db):(host):(port)
# Store bayesian data in MySQL
#bayes_store_module Mail::SpamAssassin::BayesStore::PgSQL
#bayes_sql_dsn DBI:Pg:database:sql_server:sql_port
#
bayes_sql_username (user)
bayes_sql_password (password)
#
# Override the username used for storing
# data in the database. This could be used to group users together to
# share bayesian filter data. You can also use this config option to
# trick sa-learn to learn data as a specific user.
#
#bayes_sql_override_username vmail
Please change the Plaseholder in : (db), (host), (port), (user), (password)
4. create mysql user, db and scheme for spamassassin bayes
# cd /root/
# wget http://svn.apache.org/repos/asf/spamassassin/tags/spamassassin_release_3_3_2/sql/bayes_mysql.sql
### NOTICE /root/bayes_mysql.sql must be modded TYPE => ENGINE for correct mysql syntax.
### CREATE DB for SA_BAYES AND IMPORT SCHEME.
# mysql -uroot -p
mysql> CREATE DATABASE sa_bayes;
mysql> USE sa_bayes;
mysql> SOURCE /root/bayes_mysql.sql;
### CREATE USER AND GIVE ACCESS (USERDATA NEEDED IN LOCAL.CF for SETTING UP SPAMASSASSIN)
mysql> GRANT SELECT, INSERT, UPDATE, DELETE ON sa_bayes.* TO sa_user@localhost IDENTIFIED BY 'sa_user_password';
mysql> FLUSH PRIVILEGES;
mysql> EXIT;
5. RESTART DOVECOT, AMAVIS(-NEW)
# service dovecot restart
# service amavis restart
6. Its Done,
Now all emails that are push to spamfolder, via IMAP will now learned by SA if you get an mail in Spamfolder, that is not Spam, push it to an other Folder like Inbox and it will learned as -ham
I hope, it will help you!
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.