This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
start:howto:spamassassin-user-prefs-sql [2012/07/30 08:51] BeNe |
start:howto:spamassassin-user-prefs-sql [2015/01/19 23:40] ninos removed |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | **This HowTo is old. Please use following plugin! | ||
+ | http://i-mscp.net/filebase/index.php/File/14-SpamAssassin/** | ||
+ | |||
====== Info ====== | ====== Info ====== | ||
- | **This is more a less a DRAFT (Version 0.1) and should not be use on a productive system! \\ | + | This HowTo is more or less ready for use. \\ |
- | The HowTo is not ready but i will make it public so that other user can go on with it. \\ | + | |
Feel free to change it ;-) | Feel free to change it ;-) | ||
- | For any question use the Forum or PM me (BeNe)** | + | For any question use the Forum or PM me (BeNe) |
====== Needed Packages ====== | ====== Needed Packages ====== | ||
- | aptitude install | + | <code> |
- | libaprutil1-dbd-mysql | + | aptitude update |
- | razor | + | </code> |
- | libnet-dns-perl | + | <code> |
- | libmailtools-perl | + | aptitude install libaprutil1-dbd-mysql razor libnet-dns-perl libmailtools-perl spamc spamassassin libmail-dkim-perl dkim-filter clamsmtp libtie-cache-perl libdbd-mysql-perl pyzor |
- | spamc | + | </code> |
- | spamassassin | + | |
- | libmail-dkim-perl | + | |
- | dkim-filter | + | |
- | clamsmtp | + | |
- | libtie-cache-perl | + | |
- | libdbd-mysql-perl | + | |
- | pyzor | + | |
====== Spamassassin ====== | ====== Spamassassin ====== | ||
- | ===== User spamd ===== | + | ===== Create user spamd ===== |
<code> | <code> | ||
groupadd -g 5001 spamd | groupadd -g 5001 spamd | ||
Line 29: | Line 24: | ||
mkdir /var/lib/spamassassin | mkdir /var/lib/spamassassin | ||
chown spamd:spamd /var/lib/spamassassin | chown spamd:spamd /var/lib/spamassassin | ||
- | </code> | ||
- | |||
- | ===== /etc/default/spamassassin ===== | ||
- | Change the file like this: | ||
- | <code> | ||
- | ENABLED=1 | ||
- | SAHOME="/var/lib/spamassassin/" | ||
- | OPTIONS="-d -q --create-prefs --max-children 5 --username spamd --helper-home-dir ${SAHOME} -s ${SAHOME}spamd.log" | ||
- | PIDFILE="${SAHOME}spamd.pid" | ||
</code> | </code> | ||
Line 44: | Line 30: | ||
<code> | <code> | ||
rewrite_header Subject [***** SPAM _SCORE_ *****] | rewrite_header Subject [***** SPAM _SCORE_ *****] | ||
- | required_score 2.0 | + | required_score 5.0 |
#to be able to use _SCORE_ we need report_safe set to 0 | #to be able to use _SCORE_ we need report_safe set to 0 | ||
#If this option is set to 0, incoming spam is only modified by adding some "X-Spam-" headers and no changes will be made to the body. | #If this option is set to 0, incoming spam is only modified by adding some "X-Spam-" headers and no changes will be made to the body. | ||
Line 58: | Line 44: | ||
# Enable or disable network checks | # Enable or disable network checks | ||
skip_rbl_checks 0 | skip_rbl_checks 0 | ||
- | use_razor2 0 | + | use_razor2 1 |
- | #use_dcc 0 | + | use_dcc 0 |
- | use_pyzor 0 | + | use_pyzor 1 |
</code> | </code> | ||
Line 75: | Line 61: | ||
smtp inet n - - - - smtpd | smtp inet n - - - - smtpd | ||
-o content_filter=spamassassin | -o content_filter=spamassassin | ||
- | # -o receive_override_options=no_address_mappings | + | -o receive_override_options=no_address_mappings |
</code> | </code> | ||
+ | First option is to activate spamassassin. | ||
+ | Second option prevents that some forwarded mails are sent twice. | ||
Add on the end of the file: | Add on the end of the file: | ||
Line 83: | Line 71: | ||
flags=Rq user=vmail argv=/usr/bin/spamc -u ${user}@${domain} -e /usr/sbin/sendmail -oi -f ${sender} ${recipient} | flags=Rq user=vmail argv=/usr/bin/spamc -u ${user}@${domain} -e /usr/sbin/sendmail -oi -f ${sender} ${recipient} | ||
</code> | </code> | ||
+ | |||
===== /etc/postfix/main.cf ===== | ===== /etc/postfix/main.cf ===== | ||
Add to main.cf | Add to main.cf | ||
Line 92: | Line 81: | ||
===== Create MySQL User ===== | ===== Create MySQL User ===== | ||
+ | |||
+ | ToDO: Need more priviliges to create, update... | ||
<code> | <code> | ||
mysql -h localhost -u root -p | mysql -h localhost -u root -p | ||
Line 104: | Line 95: | ||
===== Import SQL-Files ===== | ===== Import SQL-Files ===== | ||
<code> | <code> | ||
- | /usr/share/doc/spamassassin/sql# mysql -u spamassassin -p YoUrPaSSworD < awl_mysql.sql | + | mysql -u spamassassin -p spamassassin < /usr/share/doc/spamassassin/sql/awl_mysql.sql |
- | /usr/share/doc/spamassassin/sql# mysql -u spamassassin -p YoUrPaSSworD < userpref_mysql.sql | + | mysql -u spamassassin -p spamassassin < /usr/share/doc/spamassassin/sql/userpref_mysql.sql |
- | /usr/share/doc/spamassassin/sql# mysql -u spamassassin -p YoUrPaSSworD < bayes_mysql.sql | + | mysql -u spamassassin -p spamassassin < /usr/share/doc/spamassassin/sql/bayes_mysql.sql |
</code> | </code> | ||
Line 112: | Line 103: | ||
<code> | <code> | ||
# mysql -u spamassassin -p | # mysql -u spamassassin -p | ||
+ | use spamassassin; | ||
INSERT INTO userpref (username,preference,value) VALUES ('$GLOBAL','required_hits','5.0'); | INSERT INTO userpref (username,preference,value) VALUES ('$GLOBAL','required_hits','5.0'); | ||
INSERT INTO userpref (username,preference,value) VALUES ('$GLOBAL','report_safe','1'); | INSERT INTO userpref (username,preference,value) VALUES ('$GLOBAL','report_safe','1'); | ||
Line 153: | Line 145: | ||
# Change to one to enable spamd | # Change to one to enable spamd | ||
- | ##ENABLED=0 | + | ENABLED=1 |
+ | |||
+ | # Set new created SAHOME | ||
+ | SAHOME="/var/lib/spamassassin/" | ||
# Options | # Options | ||
Line 163: | Line 158: | ||
##OPTIONS="--create-prefs --max-children 5 --helper-home-dir" | ##OPTIONS="--create-prefs --max-children 5 --helper-home-dir" | ||
+ | OPTIONS="-d -q -x --create-prefs --max-children 5 --username spamd --helper-home-dir ${SAHOME} -s ${SAHOME}spamd.log" | ||
# Pid file | # Pid file | ||
Line 169: | Line 165: | ||
# Otherwise, the init script will not be able to shut spamd down. | # Otherwise, the init script will not be able to shut spamd down. | ||
##PIDFILE="/var/run/spamd.pid" | ##PIDFILE="/var/run/spamd.pid" | ||
+ | PIDFILE="${SAHOME}spamd.pid" | ||
# Set nice level of spamd | # Set nice level of spamd | ||
Line 177: | Line 174: | ||
# spamassassin's rules on a nightly basis | # spamassassin's rules on a nightly basis | ||
CRON=0 | CRON=0 | ||
- | |||
- | ENABLED=1 | ||
- | SAHOME="/var/lib/spamassassin/" | ||
- | OPTIONS="-d -q --create-prefs --max-children 5 --username spamd --helper-home-dir ${SAHOME} -s ${SAHOME}spamd.log" | ||
- | PIDFILE="${SAHOME}spamd.pid" | ||
</code> | </code> | ||
- | ===== Cron ===== | + | ===== FOR DEBUG ===== |
- | <code> | + | Please use this just for debug (no daemonize) |
- | 13 */2 * * * /usr/local/bin/sa-update && /etc/init.d/spamassassin restart | + | |
- | </code> | + | |
- | + | ||
- | ===== DEBUG ===== | + | |
<code> | <code> | ||
spamd -D -q -x --create-prefs --max-children 5 --username spamd --helper-home-dir /var/lib/spamassassin/ -s /var/lib/spamassassin/spamd.log --pidfile=/var/lib/spamassassin/spamd.pid | spamd -D -q -x --create-prefs --max-children 5 --username spamd --helper-home-dir /var/lib/spamassassin/ -s /var/lib/spamassassin/spamd.log --pidfile=/var/lib/spamassassin/spamd.pid | ||
Line 196: | Line 183: | ||
====== ClamSMTP ====== | ====== ClamSMTP ====== | ||
- | ===== /etc/clamsmtp ===== | + | We use ClamSMTP for AntiVirus |
+ | ===== /etc/clamsmtp.conf ===== | ||
<code> | <code> | ||
Line 248: | Line 236: | ||
# virus is found. Read the man page for clamsmtpd.conf for details. | # virus is found. Read the man page for clamsmtpd.conf for details. | ||
- | VirusAction: /usr/local/bin/clamsmtpvirus.sh | + | ##VirusAction: /usr/local/bin/clamsmtpvirus.sh |
</code> | </code> | ||
===== Action Script ===== | ===== Action Script ===== | ||
+ | There is no need to enable an ActionScript, but there is one ;-) | ||
<code> | <code> | ||
#!/bin/bash | #!/bin/bash | ||
Line 336: | Line 324: | ||
</code> | </code> | ||
- | ===== master.cf ===== | + | ===== /etc/postfix/master.cf ===== |
<code> | <code> | ||
Line 355: | Line 343: | ||
</code> | </code> | ||
- | ===== main.cf ===== | + | ===== /etc/postfix/main.cf ===== |
<code> | <code> | ||
Line 417: | Line 405: | ||
====== ToDo ====== | ====== ToDo ====== | ||
- | Mark as Junk2 Plugin for RC\\ | + | Mark as Junk2 Plugin for RC 0.8.x\\ |
- | sa-learn works ? \\ | + | |
- | This and that \\ | + |