1 (edited by maciejm 2014-12-04 21:39:05)

Topic: easy way to learn SA from webmail use dovecot + antispam in iredmail

==== Required information ====
- iRedMail version: 0.8.7
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): mysql
- Linux/BSD distribution name and version: debian wheezy
- Related log if you're reporting an issue:
====


Hi
This is small faq to enable learning SA from webmail for vusers - antispam in dovecot for iredmail smile


1)install packages:

apt-get install dovecot-antispam

2)edit dovecot.conf

pico /etc/dovecot/dovecot.conf

find:

in sections plugin add:

plugin {

.......

antispam_debug_target = syslog
antispam_verbose_debug = 1
antispam_backend = pipe
antispam_trash = Trash
antispam_spam = Junk
antispam_pipe_program = /usr/bin/sa-learn-pipe.sh
antispam_pipe_program_spam_arg = --spam
antispam_pipe_program_notspam_arg = --ham

....
}

find sections protocol imap and add antispam

protocol imap {
    mail_plugins = $mail_plugins imap_quota acl imap_acl antispam

....
}

3)edit antispam_pipe_program:

pico /usr/bin/sa-learn-pipe.sh

---------------------- start -------------------------------------------------------

#!/bin/bash
echo /usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt
echo "$$-start ($*)" >> /tmp/sa-learn-pipe.log

echo $* > /tmp/sendmail-parms.txt
cat<&0 >> /tmp/sendmail-msg-$$.txt

chmod 644 /tmp/sendmail-msg-$$.txt
sudo -u amavis /usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt -u spamd --dbpath /var/lib/amavis/.spamassassin
echo sudo -u amavis /usr/bin/sa-learn $* /tmp/sendmail-msg-$$.txt -u spamd --dbpath /var/lib/amavis/.spamassassin >>  /tmp/sa-learn-pipe.log
echo $$ sa-learn rc=$? id=$(id) HOME=$HOME >> /tmp/sa-learn-pipe.log

rm -f /tmp/sendmail-msg-$$.txt

echo "$$-end" >> /tmp/sa-learn-pipe.log

exit 0

-------------------------------------------------- stop --------------------------------------------

chmod +x /usr/bin/sa-learn-pipe.sh

4)add user to sudo:

vmail ALL =(amavis) NOPASSWD: /usr/bin/sa-learn

5)edit config.inc.php in roundcube and add:

pico /usr/share/apache2/roundcubemail/config/config.inc.php

add:

$config['plugins'] = array('managesieve', 'password', 'acl', 'markasjunk', 'identity_select', 'new_user_identity');

6)now is done smile go to coffie or beer



How test:

su - amavis -s /bin/bash
sa-learn --dump magic
0.000          0          3          0  non-token data: bayes db version
0.000          0         26          0  non-token data: nspam
0.000          0         16          0  non-token data: nham
0.000          0       2047          0  non-token data: ntokens
0.000          0 1416931283          0  non-token data: oldest atime
0.000          0 1417689280          0  non-token data: newest atime
0.000          0          0          0  non-token data: last journal sync atime
0.000          0 1417652647          0  non-token data: last expiry atime
0.000          0          0          0  non-token data: last expire atime delta
0.000          0          0          0  non-token data: last expire reduction coun

now log to your e-mail acount in roundcube and add e-mail to spam and test:

sa-learn --dump magic
0.000          0          3          0  non-token data: bayes db version
0.000          0         27          0  non-token data: nspam
0.000          0         15          0  non-token data: nham
0.000          0       2047          0  non-token data: ntokens
0.000          0 1416931283          0  non-token data: oldest atime
0.000          0 1417689280          0  non-token data: newest atime
0.000          0          0          0  non-token data: last journal sync atime
0.000          0 1417652647          0  non-token data: last expiry atime
0.000          0          0          0  non-token data: last expire atime delta
0.000          0          0          0  non-token data: last expire reduction count

Im tuned more in iredmail but not write in post because this is free version because author iredmail can not accept smile

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: easy way to learn SA from webmail use dovecot + antispam in iredmail

Thanks for your sharing. smile

3

Re: easy way to learn SA from webmail use dovecot + antispam in iredmail

Nice. I've been looking for this type of solution for quite a while. Only problem is it crashes. lol.

I started with your code then modified it down to what I can execute on the commandline and it bails the same way.

*** apport.log ***
ERROR: apport (pid 14391) Fri Dec 26 15:08:23 2014: called for pid 14374, signal 6, core limit 0
ERROR: apport (pid 14391) Fri Dec 26 15:08:23 2014: script: /usr/bin/sa-learn, interpreted by /usr/bin/perl (command line "/usr/bin/perl -T\ -w /usr/bin/sa-learn --spam --username=vmail /tmp/sendmail-msg-14371.txt")
ERROR: apport (pid 14391) Fri Dec 26 15:08:23 2014: is_closing_session(): no DBUS_SESSION_BUS_ADDRESS in environment

It works on the commandline it does not work in the script. I am really at a loss for why it would work one way and not the other when both shells are the same.

Anecdotally my sa-learn is really slow, takes about a minute to execute which I can't trace down either. Not hurting with the CPU and I reset the bayes mysql tokens to see if it was corruption. Trying to trace down that oddity as well.

4

Re: easy way to learn SA from webmail use dovecot + antispam in iredmail

Its like my tutorial: http://www.iredmail.org/forum/topic8169.html

You dont need some crap!

5

Re: easy way to learn SA from webmail use dovecot + antispam in iredmail

Dovecot and  antispam plugin not work on ubuntu 16.04
iredmail 0.9.5-1
I try to repeat this solution and  stuck, no new files in /tmp/
Many searches and strace'ing bring me  answer: dovecot can't write to /tmp when launch on startup like service. When it's running like root all works. Permissions are good to get  vmail user write in it. Seems to bug.
So, replace "/tmp" on /var/vmail solve it. Hope some one need this:)