spamassassin:mysql_config
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | |||
spamassassin:mysql_config [2016/11/14 14:07] – peter | spamassassin:mysql_config [2019/12/04 21:14] (current) – removed peter | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== SpamAssassin - MySQL config ====== | ||
- | configure SpamAssassin to store its volatile data in a MySQL database | ||
- | |||
- | In **/ | ||
- | |||
- | ===== Create a database and a user in MySQL ===== | ||
- | |||
- | <code bash> | ||
- | mysql -u root -p mysql << | ||
- | CREATE DATABASE spamassassin; | ||
- | CREATE USER ' | ||
- | GRANT ALL ON spamassassin.* TO ' | ||
- | FLUSH PRIVILEGES; | ||
- | EOF | ||
- | </ | ||
- | |||
- | |||
- | ===== Setting up users' score ===== | ||
- | |||
- | |||
- | SpamAssassin can load user specific settings from the database, if the **user_scores_dsn** variable is set (and spamd is started with the --sql-config option). | ||
- | |||
- | < | ||
- | user_scores_dsn | ||
- | user_scores_sql_username | ||
- | user_scores_sql_password | ||
- | </ | ||
- | |||
- | For the default query to work the **userpref** table must have at least the username, preference and value fields. | ||
- | |||
- | <code mysql> | ||
- | CREATE TABLE userpref ( | ||
- | username varchar(100) NOT NULL default '', | ||
- | preference varchar(50) NOT NULL default '', | ||
- | value varchar(100) NOT NULL default '', | ||
- | prefid int(11) NOT NULL auto_increment, | ||
- | PRIMARY KEY (prefid), | ||
- | KEY username (username)); | ||
- | |||
- | INSERT INTO userpref (username, preference, value) VALUES (' | ||
- | # INSERT INTO userpref (username, preference, value) VALUES (' | ||
- | </ | ||
- | |||
- | ===== Setting up the auto-whitelist configuration ===== | ||
- | |||
- | The setting below tells SpamAssassin to use the auto-whitelist in the SQL database. | ||
- | |||
- | < | ||
- | auto_whitelist_factory | ||
- | |||
- | user_awl_dsn | ||
- | user_awl_sql_username | ||
- | user_awl_sql_password | ||
- | user_awl_sql_table | ||
- | </ | ||
- | |||
- | Here is the default table layout: | ||
- | |||
- | <code mysql> | ||
- | CREATE TABLE awl ( | ||
- | username varchar(100) NOT NULL default '', | ||
- | email varchar(255) NOT NULL default '', | ||
- | ip varchar(40) NOT NULL default '', | ||
- | count int(11) NOT NULL default ' | ||
- | totscore float NOT NULL default ' | ||
- | signedby varchar(255) NOT NULL default '', | ||
- | PRIMARY KEY (username, email, signedby, ip)); | ||
- | </ | ||
- | | ||
- | SpamAssassin only adds data to the auto-whitelist table and does not delete from it. Hence it is suggested to change the table to include a timestamp of the last modification for each record. | ||
- | |||
- | <code mysql> | ||
- | ALTER TABLE awl ADD lastupdate timestamp default CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP; | ||
- | UPDATE awl SET lastupdate = NOW() WHERE lastupdate < 1; | ||
- | </ | ||
- | |||
- | The following statements delete entries that are older than 6 months and addresses that occurred only once in the past 15 days. | ||
- | |||
- | <code mysql> | ||
- | DELETE FROM awl WHERE lastupdate <= DATE_SUB(SYSDATE(), | ||
- | DELETE FROM awl WHERE count = 1 AND lastupdate <= DATE_SUB(SYSDATE(), | ||
- | </ | ||
- | |||
- | |||
- | ===== Setting up the Bayes configuration ===== | ||
- | |||
- | The Bayes settings are similar to the ones seen above. | ||
- | |||
- | < | ||
- | bayes_store_module | ||
- | |||
- | bayes_sql_dsn | ||
- | bayes_sql_username | ||
- | bayes_sql_password | ||
- | # | ||
- | </ | ||
- | |||
- | The tables with the default layout are created with the following commands. | ||
- | |||
- | <code mysql> | ||
- | CREATE TABLE bayes_expire ( | ||
- | id int(11) NOT NULL default ' | ||
- | runtime int(11) NOT NULL default ' | ||
- | KEY bayes_expire_idx1 (id)); | ||
- | |||
- | CREATE TABLE bayes_global_vars ( | ||
- | variable varchar(30) NOT NULL default '', | ||
- | value varchar(200) NOT NULL default '', | ||
- | PRIMARY KEY (variable)); | ||
- | |||
- | INSERT INTO bayes_global_vars VALUES (' | ||
- | |||
- | CREATE TABLE bayes_seen ( | ||
- | id int(11) NOT NULL default ' | ||
- | msgid varchar(200) binary NOT NULL default '', | ||
- | flag char(1) NOT NULL default '', | ||
- | PRIMARY KEY (id, msgid)); | ||
- | |||
- | CREATE TABLE bayes_token ( | ||
- | id int(11) NOT NULL default ' | ||
- | token char(5) NOT NULL default '', | ||
- | spam_count int(11) NOT NULL default ' | ||
- | ham_count int(11) NOT NULL default ' | ||
- | atime int(11) NOT NULL default ' | ||
- | PRIMARY KEY (id, token), INDEX bayes_token_idx1 (id, atime)); | ||
- | |||
- | CREATE TABLE bayes_vars ( | ||
- | id int(11) NOT NULL AUTO_INCREMENT, | ||
- | username varchar(200) NOT NULL default '', | ||
- | spam_count int(11) NOT NULL default ' | ||
- | ham_count int(11) NOT NULL default ' | ||
- | token_count int(11) NOT NULL default ' | ||
- | last_expire int(11) NOT NULL default ' | ||
- | last_atime_delta int(11) NOT NULL default ' | ||
- | last_expire_reduce int(11) NOT NULL default ' | ||
- | oldest_token_age int(11) NOT NULL default ' | ||
- | newest_token_age int(11) NOT NULL default ' | ||
- | PRIMARY KEY (id), | ||
- | UNIQUE bayes_vars_idx1 (username)); | ||
- | </ | ||
- | |
spamassassin/mysql_config.1479132434.txt.gz · Last modified: 2020/07/15 09:30 (external edit)