
OTRS Help Desk is an open source application (with Enterprise support) that has a lot of useful features: ITSM, Surveys, Time Accounting and System monitoring.
I use it on my company as a Service Desk for Security purposes (and more).
As you can read from our Success Story one of the feature we currently appreciate is the ability to track all the email exchanges into tickets simply putting ticket number in email Subject end CCing the proper configured email address. This allow us to interact with external parties without the need for other people to access our OTRS istance.
A usability improvement that my colleagues asked for is the ability to insert multiple ticket numbers in the email Subject and allow OTRS to add the email content to all the tickets referenced in the Subject. By default this won’t happen, OTRS just “deliver” the email to the first ticket found in the email Subject.
I had a look into OTRS perl code and found that OTRS (I run version 4.x) cannot be easly patched to allow the requested behavior; version 4.x (didn’t tried v5) is designed to process and deliver to one ticket at time.
But…
My OTRS Service Desk run on top of Ubuntu 14.04 server and all the incoming and outgoing emails are delivered via postfix MTA. When an email comes to OTRS server is delivered to the local user (otrs) using procmail MDA and then sent to OTRS perl file otrs.PostMaster.pl that handles all the needeed tasks (parsing, insert in existing tickets…).
Follow default configuration:
file: /etc/postfix/main.cf
mailbox_command = procmail -a "$EXTENSION"
file: ~otrs/.procmail
# Pipe all email into the PostMaster process.
:0 :
| $SYS_HOME/bin/otrs.PostMaster.pl
The idea is very simple.
Write a wrapper that intercepts the flow between postfix and procmail, parses the email Subject and, if needed (multiple ticket reference found in the Subject) splits the incoming email in multiple emails, modifying email Subject and delivering the new emails to procmail.
So i wrote a perl script called otrs.procmail_wrapper.pl (code here) and created this github repository.
To give a try to the script, just copy it in dir /opt/otrs_scripts/ and modify postfix mailbox_command directive as follow
file: /etc/postfix/main.cf
mailbox_command = /opt/otrs_scripts/otrs.procmail_wrapper.pl -a "$EXTENSION"
Then modify script vars based on your OTRS and system environment
############################# # !! MODIFY HERE USING YOUR SPECIFIC ENVIRONMNET VALUES !! # Config vars - the same var names OTRS use my $TicketHook = "Ticket"; my $TicketHookDivider = "-"; my $SystemID = "77"; # Program to be executed via system call # /usr/bin/procmail is default for Ubuntu installation my $ExternalProgram = "/usr/bin/procmail";
Then restart postfix (service postfix restart) and try the new feature putting multiple ticket numbers in the email Subject.
The script log to syslog and require Email::Simple; you can download end install Email::Simple on CPAN or install in Ubuntu as follow
# apt-get install build-essentials # cpan cpan> install Email::Simple [...] cpan> quit
Before install the script, test it using email.sample provided on github
root@goblinshark:/opt/otrs_scripts# ./otrs.procmail_wrapper.pl < email.sample Writing email to tmp file: /tmp/7TNABhImw2 Subject: Test OTRS Tickets: Ticket-2015030377000139 [Ticket-2015030377000123] Ticket-2015030377000141 Ticket-2015030377000123 Ticket-2015030377000155 Number of unique ticket references in Subject: 4 Remove Ticket other than Ticket-2015030377000139 from Subject - removing Ticket-2015030377000123 from Subject - removing Ticket-2015030377000141 from Subject - removing Ticket-2015030377000155 from Subject Sending with new Subject: Test OTRS Tickets: Ticket-2015030377000139 [] Remove Ticket other than Ticket-2015030377000123 from Subject - removing Ticket-2015030377000139 from Subject - removing Ticket-2015030377000141 from Subject - removing Ticket-2015030377000155 from Subject Sending with new Subject: Test OTRS Tickets: [Ticket-2015030377000123] Ticket-2015030377000123 Remove Ticket other than Ticket-2015030377000141 from Subject - removing Ticket-2015030377000139 from Subject - removing Ticket-2015030377000123 from Subject - removing Ticket-2015030377000155 from Subject Sending with new Subject: Test OTRS Tickets: [] Ticket-2015030377000141 Remove Ticket other than Ticket-2015030377000155 from Subject - removing Ticket-2015030377000139 from Subject - removing Ticket-2015030377000123 from Subject - removing Ticket-2015030377000141 from Subject Sending with new Subject: Test OTRS Tickets: [] Ticket-2015030377000155 root@goblinshark:/opt/otrs_scripts# root@goblinshark:/home/gmellini# mail "/var/mail/root": 4 messages 4 new >N 1 No Reply dom lug 24 08:08 43/1249 Test OTRS Tickets: Ticket-2015030377000139 [] N 2 No Reply dom lug 24 08:08 44/1273 Test OTRS Tickets: [Ticket-2015030377000123] Ticket-2015030377000123 N 3 No Reply dom lug 24 08:08 43/1249 Test OTRS Tickets: [] Ticket-2015030377000141 N 4 No Reply dom lug 24 08:08 43/1249 Test OTRS Tickets: [] Ticket-2015030377000155 ?
In your syslog you can find the same messages.
IMPORTANT: Please test the script in a test environment before going into production. Also check if the script is working as expected using the email.sample file provided.
I tested the script without problems in my environment that receive a normal (not too much) amount of email per day.
[More on OTRS: Fix OTRS compatibility problems with Internet Explorer via Active Directory GPO]
Hi Giovanni, very nice. Good to see that you are improving you setup 🙂
I would suggest to start the script from the .procmailrc so the postfix setup doesn’t need to be altered.
Cheers
Jens
LikeLiked by 1 person
Hi Jens 🙂 tks for suggestion, I will try and update the post… after my vacation of course 😉
LikeLike
Great, thanks.
LikeLike