• Willkommen im Linux Club - dem deutschsprachigen Supportforum für GNU/Linux. Registriere dich kostenlos, um alle Inhalte zu sehen und Fragen zu stellen.

nach löschen der SPAMS meldet Cyrus IO-ERROR

Status
Für weitere Antworten geschlossen.
Moin!

Ich habe mir ein Skript gebaut, wo SPAMS trainiert werden sollen. Nach training sollen die SPAMs wieder aus Cyrus21 Postfächer gelöscht werden. Die SPAMs habe ich mit rm -f gelöscht, leider kann ich seit der Löschung keine Mails mehr in den SPAM Ordner verschieben, von dort ich die SPAMs auch gelöscht habe...

Folgendens sehe ich im LOG:
Code:
20:10:49 mailserver cyrus/imapd[17149]: IOERROR: opening /var/spool/cyrus/mail/user/wag/SPAM/cyrus.header: No such file or directory
Was kann ich tun, dass die Mailboxen wieder brauchbar sind? Wie löscht man die SPAMs aus Cyrus - Postfächer?
 
Du kannst diese Dateien nicht einfach löschen :)
Schau in der cyrus-Dokumentation nach dem reconstruct Befehl um deine Mailbox wieder klar zu bekommen. Die Doku findest du mit "man reconstruct".

Mein cyrus hat zwei Postfächer, HAM und SPAM. In diese Postfächer kopieren meine User die false-Positives und die nicht erkannten SPAM-mails hinein.

Jeden Tag werden diese beiden Mailboxen dann via cron und den beiden Scripten bearbeitet.

Ich habe dazu diese beiden Scripte in /usr/local/sbin.
In dem perl-script musst du deine Server-Daten und dein vscan-Passwort eintragen.

Das Lernen wird getriggert via cron:
Code:
ls -al /etc/cron.daily/snake.learnSpam
lrwxrwxrwx    1 root     root           27 Nov 26  2004 /etc/cron.daily/snake.learnSpam -> /usr/local/sbin/myLearnSpam

myLearnSpam
Code:
#!/bin/sh

#umask 022
PROGNAME=`basename $0`

logger -p mail.info -t $PROGNAME "learning SPAM/NOSPAM ..."

# stop fetchmail
/sbin/rcfetchmail stop

# IMAPClient-Variante (user: vscan)
su - vscan -s "/bin/bash" -c "/usr/local/sbin/myIMAPSpamClient.pl | logger -p mail.info -t $PROGNAME"

logger -p mail.info -t $PROGNAME "finished"

# start fetchmail
/sbin/rcfetchmail start

exit 0

myIMAPSpamClient.pl
Code:
#!/usr/bin/perl
#
# Process mail from imap server shared folder 'SPAM' & 'NOSPAM' through
# spamassassin sa-learn
#
# Things to try if it doesn't work
# 1) Turn debug onto 1 and see if you connect to imap server ad get messages
# 2) Check your /etc/mail/spamassassin/local.cf for spamassassin bayes_path settings.
#
# changelog:
#
# 02.11.2004 deleteMsg flag inserted
# 28.10.2004 debug-total flag inserted
# 27.10.2004 --no-rebuild ==> --no-sync
# 27.10.2004 --rebuild    ==> --sync

use Mail::IMAPClient;

print "========================\nmyIMAPClient.pl started\n";

my $debug=0;
my $debug_total=0;
my $deleteMsg=1;
my $salearn;

#####################
# login as user vscan
#####################
my $imap = Mail::IMAPClient->new( Server=>         'MEINE:DOMAIN:XXX:143',
                                  User =>          'vscan',
                                  Password =>      'GEHEIM',
                                  Authmechanism => 'CRAM-MD5',
                                  Debug =>         $debug);
if (!defined($imap)) {
        die "IMAP Login Failed";
}

#############################################
# print out the total counts for each mailbox
#############################################
my $spamcount = $imap->message_count('user.SPAM');
print "-------\n", $spamcount, " SPAM to process\n";

my $nonspamcount = $imap->message_count('user.NOSPAM');
print $nonspamcount, " HAM to process\n-------\n";

##########################
# Process the spam mailbox
##########################
$imap->select('user.SPAM');
my @msgs = $imap->search("ALL");
for (my $i=0;$i <= $#msgs; $i++) {
        $imap->message_to_file("/tmp/salearn",$msgs[$i]);

        # execute sa-learn w/data
        if ($debug) {
                $salearn = `/usr/bin/sa-learn -D --no-sync --showdots --spam /tmp/salearn`;
        }
        else {
                $salearn = `/usr/bin/sa-learn --no-sync --spam /tmp/salearn`;
        }
        print "-------\nSPAM: ", $salearn, "\n-------\n" if $debug;

        # delete processed message
        if ($deleteMsg) {
                $imap->delete_message($msgs[$i]);
        }
        unlink("/tmp/salearn");
}
$imap->expunge();
$imap->close();


##############################
# Process the not-spam mailbox
##############################
$imap->select('user.NOSPAM');
my @msgs = $imap->search("ALL");
for (my $i=0;$i <= $#msgs; $i++) {
        $imap->message_to_file("/tmp/salearn",$msgs[$i]);

        # execute sa-learn w/data
        if ($debug) {
                $salearn = `/usr/bin/sa-learn -D --no-sync --showdots --ham /tmp/salearn`;
        }
        else {
                $salearn = `/usr/bin/sa-learn --no-sync --ham /tmp/salearn`;
        }
        print "-------\nNOSPAM: ",$salearn,"\n-------\n" if $debug;

        # delete processed message
        $imap->delete_message($msgs[$i]);
        unlink("/tmp/salearn");
}
$imap->expunge();
$imap->close();

###############
# close session
###############
$imap->logout();


#########################
# integrate learned stuff
#########################
if ($debug_total) {
        my $sarebuild = `/usr/bin/sa-learn -D --sync`;
}
else {
        my $sarebuild = `/usr/bin/sa-learn --sync`;
}
print "-------\nRebuild: ", $sarebuild, "\n-------\nmyIMAPClient.pl finished\n========================\n";
 
OP
F

fly

Thanks, mit restruct Befehl konnte ich die SPAM Postfächer wieder brauchbar machen :D

Ich habe auch ein Skript, der die SPAMS und OK Verzeichnisse untersucht... allerdings läuft es über bash Shell... Ich werde mir das Perl Skript genauer ansehen, danke!
 
Status
Für weitere Antworten geschlossen.
Oben