Moving to Spam Queue but old Scrips are still triggered


#1

Good Nighttime,
I’m using Requesttracker 4.4.x to handle the ingoing requests. Filtering out spam is done by SpamAssassin, which adds the score into the header of the e-mail. I’m planing to use this information to move all e-mails/tickets above a given score to the spam queue.

Setup:

  1. A new queue called Spam was created.
  2. All Scrips that send out E-Mails on the global level have been removed from the Spam queue
  3. A Scrip with the following configuration has been created

Condition:

return 0 unless $self->TransactionObj->Type eq "Create";
return 0 if $self->TicketObj->QueueObj->Name eq "Spam";
return 1;

Preparation:

my $spamscore = 5;
my $match     = '\*' x $spamscore;
my $inMessage = $self->TransactionObj->Attachments->First;
return 0 if ( !$inMessage );
return 0 if ( !$inMessage->GetHeader('Received') );
my $spamLevel = $inMessage->GetHeader('X-Spam-Level');

my $spam = ( $spamLevel !~ /$match/i ) ? 0 : 1;

if ($spam) {
    my $newqueue = 'Spam';
    $self->TicketObj->SetQueue($newqueue);
    $self->TicketObj->SetStatus('rejected');
}
return 1;

Cleanup:

my $score = $self->TransactionObj->Attachments->First->GetHeader('X-Spam-Score');
unless ($score) {
    my $t =$self->TransactionObj->Attachments->First > GetHeader('X-Spam-Status');
    $t = ~/score=(-?\d+(|:.\d+)?)/ && ( $score = $1 );
}

$self->TicketObj->DeleteWatcher( Type => 'Requestor' );
$self->TicketObj->DeleteWatcher( Type => 'Cc' );
$self->TicketObj->DeleteWatcher( Type => 'AdminCC' );
$self->TicketObj->DeleteWatcher( Type => 'Owner' );
$self->TicketObj->SetPriority( -int($score) ) if $score;

return 1;

Problem:
After sending the GTUBE Test-Mail the e-mail is still send out to the AdminCC with the wrong queue in the subject. If I’m looking the ticket up into the webinterface the actions are successfully performed.

How can I adjust this scrip to prevent outgoing e-mails in case of detected spam?

Thank you in advance!


#2

$self->TicketObj->DeleteWatcher( Type => ‘AdminCC’ );

Does this work or should the field be ‘AdminCc’?


#3

It neither works with the changed upper/lowercase, nor if it remove those statements alltogether


#4

Is this scrip attached to the non-spam queue? Does that queue have scrips that can email still, and if so, are any running before this scrip does?


#5

The scrip is attached to all queues with the highest priority in the overview and namend 00000 Move to Spam. Every other scrip has a a higher number than this one.