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:
- A new queue called Spam was created.
- All Scrips that send out E-Mails on the global level have been removed from the Spam queue
- 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!