Re: как imap папки автоматом обучать spamassassin по ночам?
Ilya S. Sapytsky -> debian-russian@lists.debian.org @ Fri, 19 May 2006 13:44:48 +0400:
ISS> Return-Path: <bounce-debian-russian=ran=ran.pp.ru@lists.debian.org>
ISS> X-Original-To: ran@ran.pp.ru
ISS> Delivered-To: ran@ran.pp.ru
ISS> Received: from localhost (localhost [127.0.0.1]) by castle.ran.pp.ru (Postfix) with ESMTP id 694D723347 for <ran@ran.pp.ru>; Fri, 19 May 2006 13:45:01 +0400 (MSD)
ISS> Received: from castle.ran.pp.ru ([127.0.0.1]) by localhost (castle [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 26048-05 for <ran@ran.pp.ru>; Fri, 19 May 2006 13:44:58 +0400 (MSD)
ISS> Received: from murphy.debian.org (murphy.debian.org [70.103.162.31]) by castle.ran.pp.ru (Postfix) with ESMTP id 24C0823345 for <ran@ran.pp.ru>; Fri, 19 May 2006 13:44:56 +0400 (MSD)
ISS> Received: from localhost (localhost [127.0.0.1]) by murphy.debian.org (Postfix) with QMQP id EAD0012A; Fri, 19 May 2006 04:44:52 -0500 (CDT)
ISS> Old-Return-Path: <dr@dr.s.sova.net.ru>
ISS> X-Original-To: debian-russian@lists.debian.org
ISS> Received: from csd.lae.pp.ru (csd.lae.pp.ru [213.187.102.201]) by murphy.debian.org (Postfix) with ESMTP id A4A0536562 for <debian-russian@lists.debian.org>; Fri, 19 May 2006 04:44:49 -0500 (CDT)
ISS> Received: by csd.lae.pp.ru (Postfix, from userid 1013) id 4A8B31FA7DA; Fri, 19 May 2006 13:44:48 +0400 (MSD)
ISS> Date: Fri, 19 May 2006 13:44:48 +0400
ISS> From: "Ilya S. Sapytsky" <dr@dr.s.sova.net.ru>
ISS> To: debian-russian@lists.debian.org
ISS> Subject: Re: как imap папки автоматом обучать spamassassin по ночам?
ISS> Message-ID: <[🔎] 20060519134448.I2536@sova.net.ru>
ISS> Reply-To: debian-russian@lists.debian.org
ISS> References: <[🔎] 20060518142805.D2536@sova.net.ru> <[🔎] d67uj3-p2s.ln1@legba.gamic.com> <[🔎] 20060519084018.H2536@sova.net.ru> <[🔎] 26583515@wizzle.ran.pp.ru>
ISS> Mime-Version: 1.0
ISS> Content-Type: text/plain; charset=koi8-r
ISS> Content-Disposition: inline
ISS> Content-Transfer-Encoding: 8bit
ISS> User-Agent: Mutt/1.2.5.1i
ISS> In-Reply-To: <[🔎] 26583515@wizzle.ran.pp.ru>; from ran@ran.pp.ru on Fri, May 19, 2006 at 11:56:52AM +0400
ISS> X-Rc-Virus: 2005-11-10_01
ISS> X-Rc-Spam: 2006-04-09_01
ISS> Resent-Message-ID: <2bMOVB.A.hqC.UOZbEB@murphy>
ISS> Resent-From: debian-russian@lists.debian.org
ISS> X-Mailing-List: <debian-russian@lists.debian.org> archive/latest/54385
ISS> X-Loop: debian-russian@lists.debian.org
ISS> List-Id: <debian-russian.lists.debian.org>
ISS> List-Post: <mailto:debian-russian@lists.debian.org>
ISS> List-Help: <mailto:debian-russian-request@lists.debian.org?subject=help>
ISS> List-Subscribe: <mailto:debian-russian-request@lists.debian.org?subject=subscribe>
ISS> List-Unsubscribe: <mailto:debian-russian-request@lists.debian.org?subject=unsubscribe>
ISS> Precedence: list
ISS> Resent-Sender: debian-russian-request@lists.debian.org
ISS> Resent-Date: Fri, 19 May 2006 04:44:52 -0500 (CDT)
ISS> X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ran.pp.ru
ISS> X-Spam-Status: No, hits=-2.6 tagged_above=-999.0 required=5.0 tests=AWL, BAYES_00
ISS> X-Spam-Level:
ISS> On Fri, May 19, 2006 at 11:56:52AM +0400, Artem Chuprina wrote:
>> Ilya S. Sapytsky -> debian-russian@lists.debian.org @ Fri, 19 May 2006 08:40:18 +0400:
>>
>> >> > Что бы такого придумать чтобы автоматом и по всем
>> >> > пользователям и паролями не светить?
>> >>
>> >> А courier общие папки поддерживает? У нас стоит dbmail и есть общая
>> >> папка spam куда пользователи свой спам переносят - соотвественно
>> >> fetchmail извлекает только из одной папки с одного аккаунта
>>
>> ISS> Courier этой возможности вроде как не поддерживает :(
>>
>> Который в sarge - уже вроде как поддерживает. Не пробовал, правда. Я
>> поступаю проще - у меня на том же сервере есть еще и cron, и ему
>> совершенно не в падлу запустить от имени и по поручению юзер скриптик,
>> который ходит непосредственно в maildir и сует sa-learn письма оттуда.
ISS> напишите плиз какой командой и с какими опциями вы делаете
ISS> последнее?
Работающий скрипт, запускается из юзерского кронтаба. Поскольку писем
много, приходится еще использовать xargs. Живой нетривиальный конфиг
показать не могу, поскольку вполне устраивает тривиальный :-)
#!/usr/bin/perl
use strict;
chdir || die $!;
my $debug = 0;
# read config
my %conf = ('.spam' => 'spam+delete', '.sa-spam' => 'skip', '.deleted' => 'delete');
if (-r ".spamassassin/teach-sa.cf") {
open my $conf, ".spamassassin/teach-sa.cf" or die $!;
while (<$conf>) {
next if /^\s*(#|$)/;
die "Incorrect line '$_'" unless /^\s*(\S+)\s*=\s*(.*?)\s*$/;
$conf{".$1"} = $2;
}
}
exit(0) unless -d 'Maildir';
opendir my $maildir, 'Maildir' or die $!;
for (sort readdir $maildir) {
next unless substr($_,0,1) eq '.';
next if /^\.\.?$/;
next unless -d "Maildir/$_";
my $folder = substr($_,1);
next if $conf{$_} && $conf{$_} eq 'skip';
my $type = ($conf{$_} && substr($conf{$_},0,4) eq 'spam') ? 'spam' : 'non-spam';
my $command = "| xargs " . ($debug?"echo ":"") . "sa-learn " . ($type eq 'spam' ? '--spam' : '--ham') . ' --file';
my @files = <Maildir/$_/{new,cur}/*>;
if (@files) {
print "Learning $type from $folder...\n";
open(my $sa_learn, $command) or die $!;
print $sa_learn map "$_\n", @files;
if (close($sa_learn) && $conf{$_} =~ /delete$/) {
print "Deleting learned messages from $folder...\n";
unlink @files unless $debug;
print "done.\n";
}
}
}
--
Artem Chuprina
RFC2822: <ran{}ran.pp.ru> Jabber: ran@jabber.ran.pp.ru
If it's there and you can see it---it's real
If it's not there and you can see it---it's virtual
If it's there and you can't see it---it's transparent
If it's not there and you can't see it---you erased it!
IBM poster explaining virtual memory, circa 1978
Reply to: