Hi Guys,
this is in English cause OTRS is a global ticket system used in all world.
Today i’ll show you how to filter incoming email by attachment and put them in a specified queue.
I’m doing this because even if my antispam filter rulez, sometimes some email are not marked as spam so i cannot use the X-SPAM-FLAG option.
In this tutorial i’m assuming that you’ve a working OTRS system and that the email account to receive ticket is fully configured and working well.
Let’s start.
I’ve tried to build a custom Filter but i don’t want to play too much with Perl so i’m going where everything start:
otrs/Kernel/System/PostMaster
In this folder there’s the file named NewTicket.pm which is the perl module called when an email has been fetched from otrs system.
First of all: BACKUP this file cause it’s easy to damage the entire otrs system!
In this file you need to find the definition of $QueueID comment the original line and edit like this:
my $QueueID = "";
for my $Attachment ( $Self->{ParserObject}->GetAttachments() ) {
if ( $Attachment->{Filename} =~ m{(?:\.zip|\.doc|\.docm|\.js)\z}i ) {
$QueueID = "your_queue_id";
}
else {
$QueueID = $Param{QueueID} || die "need QueueID!";
}
}
my $Queue = $Kernel::OM->Get('Kernel::System::Queue')->QueueLookup(
QueueID => $QueueID,
);
Let’s see what this code do.
I’m defining the $QueueID as empty variable then i’m checking for every attachment in the email, get the file name and parse if it has an extension like .zip, .doc, .js etc.
If it’s true, i’m assign to $QueueID the ID of my Junk queue otherwise i’ll take the right queue ID.
Yes it’s done and working! (Maybe you need to restart the scheduler or entire machine because perl doesn’t like live modifications!)
Then i’m going to create a Generic Agent to delete all ticket in Junk queue on a specified date.
Let’s see how can we do that!
First of all we need to create a Generic Agent from System Administration section:
Assign a Name to this Agent:
Set the Scheduler:
Under Ticket Filter let’s choose the Junk Queue:
Do not touch anything else!
Under Ticket Commands set YES under Delete Ticket section:
Then dump your db (it’s always a good thing) and test it:
If you click on Run Job all ticket will be permanently deleted (of course they’ll be deleted every time you schedule the agent!)
Enjoy!
Hey.
Great article, but:
* you should consider to either edit a copy in Custom/Kernel/System/Postmaster/, or
* (better) create a Postmaster Filter that looks for the Attachment name.
Your point is right, i’ve tried to build a Postmaster filter for the Attachments but without success. So i really haven’t no time to spend to study the full documentation so i’ve taken the fast way. I’m sure i’ll take the documentation to improve this modification in the next future! Thanks for your suggestions!