Email reply to ticket creates new ticket when queue name contains UTF-8 character

Hi,

I am setting up completely new rt-4.4.4 instance with mysql database, and I have a problem where email replies to tickets create new tickets instead of being appended to original ticket history when queue contains UTF-8 character.

This was asked here before:

OP of above thread worked around the problem by replacing UTF-8 characters with ASCII characters, but his final question on ability to use UTF-8 characters in queue name was left unanswered.

mysql database’s collation is utf8mb4_unicode_ci. Queue Name, Description and Subject Tag are the same (IT Podrška), and are displayed properly in database (phpmyadmin), multiple email clients, and rt’s web interface.

Could this be a bug in rt-4.4.4? Or is there something i forgot to configure?

Thank you in advance.

Screenshot of queue with new tickets being incorrectly created:

I am curious if this issue can be fixed by this commit that decodes the mailgate arguments before passing them into RT:

Hi @knation,

thank you for your reply.

I applied the patch you posted, but email reply still creates new ticket instead of being appended to original one.

I even tried to create new ticket and reply to it after I applied the patch, in order to check if perhaps fix will apply only to post-patch messages, but still no luck.

I’d be glad to turn on any advanced debug options or do any additional patching and testing, as this instance is not yet in production.

Did you also restart your web server and clear the mason cache?

Are you receiving an autoreply email from RT when you are initially emailing in to create the ticket?

That autoreply should be whats adding the ticket ID to the email subject, can you confirm that you are replying to that email and not the original email where the subject lacks the ticket ID?

Not until now, thanks for the tip. This is on FreeBSD, so I did:
rm -rf /var/run/rt44/mason_data/obj/*
service apache24 restart

Yes

Confirmed. You can see it in screenshot in original post, where new ticket contains string inserted by rt like this:

(ticket 11) Re: [IT Podrška #10] AutoReply: još jedan tiket zbog UTF-a

… while if everything worked well, rt would recognize string “[IT Podrška #10]”, and append it to ticket “[IT Podrška #10]” instead of creating ticket 11.

Just to give some perspective, this is a refresh of a setup I have created almost a decade ago. I have quite some experience with setting up and maintaining rt, and have been using and customizing it for years (custom fields, lifecycles), but now I have the possibility to implement it from scratch, where I’ll be adding some more queues, and SLAs.

I know I could just replace “š” with “s” in queue fields, and everything would work again (which I’ll probably end up doing), but I thought perhaps this could be the good time to call some developers’ attention to the problem so it gets fixed for all us non-ASCII people while rt becomes even better :smiley:.

Strange, testing on my 4.4 with the same queue name “IT Podrška” I am not able to replicate the issue, but I didn’t test too exhaustively

You could try adding some debug logging to RT::Lib::Interface::Email->ParseTicketId to see what RT is finding when parsing the email subject tag

Well, if rt-4.4.4 works for you, it problably isn’t due to rt itself.

Are you also using mysql?

BTW I’m using fetchmail to pull mail from exchange mailbox via POP3. Original request is also created with email sent from Outlook.

I have turned debug logging on, and replied to Ticket #10, which created Ticket #12 (Ticket #11 was already previously created in the same way).

Perhaps someone can figure out something from the log (I have hopefully replaced real domain with example.org). I hope pasting here is ok, if not please let me know, I’ll edit post to delete log and post a link to some external service.

[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'iso-8859-2' to 'utf-8' for text/html - Re: [IT Podrška #10] AutoReply: još jedan tiket zbog UTF-a (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Mail from user #52 (frljo.frljanovic@example.org) (/usr/local/lib/perl5/site_perl/RT/Interface/Email/Auth/MailFrom.pm:94)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Tried to load a bogus ticket id: '' (/usr/local/lib/perl5/site_perl/RT/Ticket.pm:140)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: About to prepare scrips for transaction #168 (/usr/local/lib/perl5/site_perl/RT/Transaction.pm:189)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Found 8 scrips for TransactionCreate stage with applicable type(s) Create for txn #168 on ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:482)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/plain - AutoReply: Re: [IT Podrška #10] AutoReply: još jedan tiket zbog UTF-a (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/html - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/plain - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/html - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/plain - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/html - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/plain - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/html - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Skipping Scrip #11 because it isn't applicable (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:337)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: About to commit scrips for transaction #168 (/usr/local/lib/perl5/site_perl/RT/Transaction.pm:212)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Committing scrip #7 on txn #168 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Calling SetRecipientDigests for transaction RT::Transaction=HASH(0x809f85be8), id 168 (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:685)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Working on mailfield To; recipients are frljo.frljanovic@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Reply-To: nitpodrska@example.org
X-RT-Loop-Prevention: example.org
Auto-Submitted: auto-replied
Message-ID: <rt-4.4.4-3622-1593627514-1339.12-7-0@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-0"
From: "=?UTF-8?B?SVQgUG9kcsWha2E=?= putem tiketing sistema" <nitpodrska@example.org>
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gQXV0b1JlcGx5OiBSZTogW0lUIFBvZHLFoWth?= =?UTF-8?B?ICMxMF0gQXV0b1JlcGx5OiBqb8WhIGplZGFuIHRpa2V0IHpib2cgVVRGLWE=?=
X-RT-Ticket: example.org #12
To: frljo.frljanovic@example.org
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org> (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Got user mail preference 'Individual messages' for user frljo.frljanovic@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:722)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Removing deferred recipients from To: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Working on mailfield Cc; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Reply-To: nitpodrska@example.org
X-RT-Loop-Prevention: example.org
Auto-Submitted: auto-replied
Message-ID: <rt-4.4.4-3622-1593627514-1339.12-7-0@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-0"
From: "=?UTF-8?B?SVQgUG9kcsWha2E=?= putem tiketing sistema" <nitpodrska@example.org>
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gQXV0b1JlcGx5OiBSZTogW0lUIFBvZHLFoWth?= =?UTF-8?B?ICMxMF0gQXV0b1JlcGx5OiBqb8WhIGplZGFuIHRpa2V0IHpib2cgVVRGLWE=?=
X-RT-Ticket: example.org #12
To: frljo.frljanovic@example.org
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org> (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Removing deferred recipients from Cc: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Working on mailfield Bcc; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Reply-To: nitpodrska@example.org
X-RT-Loop-Prevention: example.org
Auto-Submitted: auto-replied
Message-ID: <rt-4.4.4-3622-1593627514-1339.12-7-0@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-0"
From: "=?UTF-8?B?SVQgUG9kcsWha2E=?= putem tiketing sistema" <nitpodrska@example.org>
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gQXV0b1JlcGx5OiBSZTogW0lUIFBvZHLFoWth?= =?UTF-8?B?ICMxMF0gQXV0b1JlcGx5OiBqb8WhIGplZGFuIHRpa2V0IHpib2cgVVRGLWE=?=
X-RT-Ticket: example.org #12
To: frljo.frljanovic@example.org
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org> (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Removing deferred recipients from Bcc: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:34 2020] [debug]: No recipients found for deferred delivery on transaction #168 (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:753)
[3622] [Wed Jul  1 18:18:34 2020] [info]: <rt-4.4.4-3622-1593627514-1339.12-7-0@example.org> #12/168 - Scrip 7 On Create Autoreply To Requestors (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:285)
[3622] [Wed Jul  1 18:18:35 2020] [info]: <rt-4.4.4-3622-1593627514-1339.12-7-0@example.org> sent  To: frljo.frljanovic@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:316)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: We found a part. we want to record it. (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:572)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: We found a part. we want to record it. (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:572)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/plain - AutoReply: Re: [IT Podrška #10] AutoReply: još jedan tiket zbog UTF-a (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/html - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Skipping scrips for transaction #169 (/usr/local/lib/perl5/site_perl/RT/Transaction.pm:181)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Committing scrip #8 on txn #168 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Calling SetRecipientDigests for transaction RT::Transaction=HASH(0x809f85be8), id 168 (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:685)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Working on mailfield To; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: BCC: mara.maric@example.org, misko.miskovic@example.org
X-RT-Loop-Prevention: example.org
Reply-To: nitpodrska@example.org
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
X-RT-Ticket: example.org #12
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-1"
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Message-ID: <rt-4.4.4-3622-1593627514-1480.12-8-0@example.org> (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Removing deferred recipients from To: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Working on mailfield Cc; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: BCC: mara.maric@example.org, misko.miskovic@example.org
X-RT-Loop-Prevention: example.org
Reply-To: nitpodrska@example.org
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
X-RT-Ticket: example.org #12
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-1"
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Message-ID: <rt-4.4.4-3622-1593627514-1480.12-8-0@example.org> (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Removing deferred recipients from Cc: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Working on mailfield Bcc; recipients are mara.maric@example.org,misko.miskovic@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: BCC: mara.maric@example.org, misko.miskovic@example.org
X-RT-Loop-Prevention: example.org
Reply-To: nitpodrska@example.org
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
X-RT-Ticket: example.org #12
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-1"
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Message-ID: <rt-4.4.4-3622-1593627514-1480.12-8-0@example.org> (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Got user mail preference 'Individual messages' for user mara.maric@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:722)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Got user mail preference 'Individual messages' for user misko.miskovic@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:722)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Removing deferred recipients from Bcc: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:35 2020] [debug]: No recipients found for deferred delivery on transaction #168 (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:753)
[3622] [Wed Jul  1 18:18:35 2020] [info]: <rt-4.4.4-3622-1593627514-1480.12-8-0@example.org> #12/168 - Scrip 8 On Create Notify Owner and AdminCcs (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:285)
[3622] [Wed Jul  1 18:18:37 2020] [info]: <rt-4.4.4-3622-1593627514-1480.12-8-0@example.org> sent  Bcc: mara.maric@example.org, misko.miskovic@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:316)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: We found a part. we want to record it. (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:572)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: We found a part. we want to record it. (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:572)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/plain - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Converting 'utf-8' to 'utf-8' for text/html - Subjectless message (/usr/local/lib/perl5/site_perl/RT/I18N.pm:291)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Encode::Guess guessed encoding: ascii (/usr/local/lib/perl5/site_perl/RT/I18N.pm:568)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Skipping scrips for transaction #170 (/usr/local/lib/perl5/site_perl/RT/Transaction.pm:181)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Committing scrip #9 on txn #168 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Calling SetRecipientDigests for transaction RT::Transaction=HASH(0x809f85be8), id 168 (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:685)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Working on mailfield To; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Reply-To: nitpodrska@example.org
X-RT-Loop-Prevention: example.org
X-RT-Originator: frljo.frljanovic@example.org
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-2"
Message-ID: <rt-4.4.4-3622-1593627514-1628.12-9-0@example.org>
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
X-RT-Ticket: example.org #12
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/) (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Removing deferred recipients from To: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Working on mailfield Cc; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Reply-To: nitpodrska@example.org
X-RT-Loop-Prevention: example.org
X-RT-Originator: frljo.frljanovic@example.org
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-2"
Message-ID: <rt-4.4.4-3622-1593627514-1628.12-9-0@example.org>
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
X-RT-Ticket: example.org #12
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/) (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Removing deferred recipients from Cc: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Working on mailfield Bcc; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Reply-To: nitpodrska@example.org
X-RT-Loop-Prevention: example.org
X-RT-Originator: frljo.frljanovic@example.org
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-2"
Message-ID: <rt-4.4.4-3622-1593627514-1628.12-9-0@example.org>
In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
X-RT-Ticket: example.org #12
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/) (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Removing deferred recipients from Bcc: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: No recipients found for deferred delivery on transaction #168 (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:753)
[3622] [Wed Jul  1 18:18:37 2020] [info]: <rt-4.4.4-3622-1593627514-1628.12-9-0@example.org> #12/168 - Scrip 9 On Create Notify Ccs (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:285)
[3622] [Wed Jul  1 18:18:37 2020] [info]: <rt-4.4.4-3622-1593627514-1628.12-9-0@example.org> No recipients found. Not sending. (/usr/local/lib/perl5/site_perl/RT/Interface/Email.pm:836)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Committing scrip #10 on txn #168 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Calling SetRecipientDigests for transaction RT::Transaction=HASH(0x809f85be8), id 168 (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:685)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Working on mailfield To; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
X-RT-Ticket: example.org #12
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-3"
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Message-ID: <rt-4.4.4-3622-1593627514-1760.12-10-0@example.org>
X-RT-Loop-Prevention: example.org
Reply-To: nitpodrska@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Removing deferred recipients from To: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Working on mailfield Cc; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
X-RT-Ticket: example.org #12
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-3"
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Message-ID: <rt-4.4.4-3622-1593627514-1760.12-10-0@example.org>
X-RT-Loop-Prevention: example.org
Reply-To: nitpodrska@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Removing deferred recipients from Cc: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Working on mailfield Bcc; recipients are  (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:701)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: In-Reply-To: <02992ce70554401b96a46cb0844219ff@example.org>
X-Managed-BY: RT 4.4.4 (http://www.bestpractical.com/rt/)
X-RT-Ticket: example.org #12
Subject: =?UTF-8?B?W0lUIFBvZHLFoWthICMxMl0gUmU6IFtJVCBQb2RyxaFrYSAjMTBdIEF1dG9S?= =?UTF-8?B?ZXBseTogam/FoSBqZWRhbiB0aWtldCB6Ym9nIFVURi1h?=
References: <RT-Ticket-12@example.org> <RT-Ticket-10@example.org>
 <6412d44f797c41289ae2e6a975ed27a2@example.org>,
 <rt-4.4.4-95091-1593624482-432.10-7-0@example.org>
 <02992ce70554401b96a46cb0844219ff@example.org>
Content-Type: multipart/alternative; boundary="----------=_1593627514-3622-3"
From: "=?UTF-8?B?RnJsam8gRnJsamFub3ZpxIc=?= putem tiketing sistema" <nitpodrska@example.org>
X-RT-Originator: frljo.frljanovic@example.org
Message-ID: <rt-4.4.4-3622-1593627514-1760.12-10-0@example.org>
X-RT-Loop-Prevention: example.org
Reply-To: nitpodrska@example.org (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:708)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Removing deferred recipients from Bcc: line (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:731)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Setting deferred recipients for attribute creation (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:740)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: No recipients found for deferred delivery on transaction #168 (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:753)
[3622] [Wed Jul  1 18:18:37 2020] [info]: <rt-4.4.4-3622-1593627514-1760.12-10-0@example.org> #12/168 - Scrip 10 On Create Notify Other Recipients (/usr/local/lib/perl5/site_perl/RT/Action/SendEmail.pm:285)
[3622] [Wed Jul  1 18:18:37 2020] [info]: <rt-4.4.4-3622-1593627514-1760.12-10-0@example.org> No recipients found. Not sending. (/usr/local/lib/perl5/site_perl/RT/Interface/Email.pm:836)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Committing scrip #13 on txn #168 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Committing scrip #16 on txn #168 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: About to prepare scrips for transaction #171 (/usr/local/lib/perl5/site_perl/RT/Transaction.pm:189)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Found 4 scrips for TransactionCreate stage with applicable type(s) Set for txn #171 on ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:482)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Skipping Scrip #11 because it isn't applicable (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:337)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Skipping Scrip #16 because it isn't applicable (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:337)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Skipping Scrip #17 because it isn't applicable (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:337)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: About to commit scrips for transaction #171 (/usr/local/lib/perl5/site_perl/RT/Transaction.pm:212)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Committing scrip #13 on txn #171 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Committing scrip #17 on txn #168 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Last effective outside actors' reply to ticket #12 is txn #168 (/usr/local/lib/perl5/site_perl/RT/Action/SLA_SetDue.pm:88)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: About to prepare scrips for transaction #172 (/usr/local/lib/perl5/site_perl/RT/Transaction.pm:189)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Found 4 scrips for TransactionCreate stage with applicable type(s) Set for txn #172 on ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:482)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Skipping Scrip #11 because it isn't applicable (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:337)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Skipping Scrip #16 because it isn't applicable (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:337)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Skipping Scrip #17 because it isn't applicable (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:337)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: About to commit scrips for transaction #172 (/usr/local/lib/perl5/site_perl/RT/Transaction.pm:212)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Committing scrip #13 on txn #172 of ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:293)
[3622] [Wed Jul  1 18:18:37 2020] [info]: Ticket 12 created in queue 'IT Podrška' by frljo.frljanovic (/usr/local/lib/perl5/site_perl/RT/Ticket.pm:567)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Found 0 scrips for TransactionBatch stage with applicable type(s) Create for txn #168 on ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:482)
[3622] [Wed Jul  1 18:18:37 2020] [debug]: Found 0 scrips for TransactionBatch stage with applicable type(s) Set for txn #171 on ticket #12 (/usr/local/lib/perl5/site_perl/RT/Scrips.pm:482)

Could you please give me more detailed instruction on how to do it or post some links where I can read about it?

Can you share the headers and content for one of these emails going into RT? Feel free to sanitize any email addresses.

Could you please give me more detailed instruction on how to do it or post some links where I can read about it?

You can create a local overlay of the ParseTicketId function /opt/rt4/local/lib/RT/Interface/Email_Local.pm

Then you can have the following content where all I added to the function was an error log with the subject passed:

package RT::Interface::Email;


use strict;
use warnings;
no warnings 'redefine';

=head3 ParseTicketId

Takes a string (the email subject) and searches for [subjecttag #id]

For customizations, the L<MIME::Entity> object is passed as the second
argument.

Returns the id if a match is found.  Otherwise returns undef.

=cut

sub ParseTicketId {
    my $Subject = shift;
    my $Entity = shift;

    RT::Logger->error( "Subject passed: $Subject" );

    my $rtname = RT->Config->Get('rtname');
    my $test_name = RT->Config->Get('EmailSubjectTagRegex') || qr/\Q$rtname\E/i;

    # We use @captures and pull out the last capture value to guard against
    # someone using (...) instead of (?:...) in $EmailSubjectTagRegex.
    my $id;
    if ( my @captures = $Subject =~ /\[$test_name\s+\#(\d+)\s*\]/i ) {
        $id = $captures[-1];
    } else {
        foreach my $tag ( RT->System->SubjectTag ) {
            next unless my @captures = $Subject =~ /\[\Q$tag\E\s+\#(\d+)\s*\]/i;
            $id = $captures[-1];
            last;
        }
    }
    return undef unless $id;

    $RT::Logger->debug("Found a ticket ID. It's $id");
    return $id;
}
1;

I have created the file, but not under /opt as you instructed, as on FreeBSD rt dir is /usr/local/share/rt44.

So, absolute path of the file I created is:
/usr/local/share/rt44/local/lib/RT/Interface/Email_Local.pm

It has the exact contents as you posted. But I don’t think I see anything in the log as a result.

As for the headers, here’s initial message, as seen by rt in web interface (with headers):

X-MS-Exchange-Organization-Recordreviewcfmtype: 0
X-MS-Exchange-Organization-Authsource: EXCHANGE.example.org
Accept-Language: sr-Latn-CS, sr-Latn-RS, en-US
Content-Transfer-Encoding: quoted-printable
Message-ID: <3d458804d8fb48c998ffbad5aba59253@example.org>
content-type: text/html; charset="utf-8"
From: "Frljo Frljanović" <frljo.frljanovic@example.org>
X-MS-Exchange-Organization-Network-Message-ID: 71b5e900-1f04-4e71-1890-08d81df5d750
MIME-Version: 1.0
X-MS-Exchange-Organization-SCL: -1
Thread-Index: AQHWT95wTZrjTYtskkORNzAaKr9hgQ==
Subject: Troubleshooting emails with knation
To: "nIT Podrška" <nitpodrska@example.org>
Received: from EXCHANGE.example.org [10.30.19.134] by apache.example.org with POP3 (fetchmail-6.4.8) for <fetchmail@localhost> (single-drop); Wed, 01 Jul 2020 21:37:17 +0200 (CEST)
Received: from EXCHANGE.example.org (10.30.19.134) by EXCHANGE.example.org (10.30.19.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.595.3 via Mailbox Transport; Wed, 1 Jul 2020 21:34:59 +0200
Received: from EXCHANGE.example.org (10.30.19.134) by EXCHANGE.example.org (10.30.19.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.595.3; Wed, 1 Jul 2020 21:34:58 +0200
Received: from EXCHANGE.example.org ([::1]) by EXCHANGE.example.org ([::1]) with mapi id 15.02.0595.003; Wed, 1 Jul 2020 21:34:58 +0200
Thread-Topic: Troubleshooting emails with knation
X-MS-Has-Attach: 
X-MS-Exchange-Organization-Authas: Internal
Date: Wed, 1 Jul 2020 21:34:58 +0200
X-MS-Tnef-Correlator: 
X-MS-Exchange-Organization-Authmechanism: 04
X-RT-Incoming-Encryption: Not encrypted
Content-Language: sr-Latn-CS
X-RT-Original-Encoding: iso-8859-2
X-RT-Interface: Email
Content-Length: 1014

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p>This is the inital mail which will create a ticket.</p>
<p><br>
</p>
<p>The idea is to inspect its headers, and also observe log after creating:</p>
<p><br>
</p>
<p><span>/usr/local/share/rt44/local/lib/RT/Interface/Email_Local.pm</span><br>
</p>
<p><span><br>
</span></p>
<p><span>...as instructed on:</span></p>
<p><span><br>
</span></p>
<p><span><a href="https://forum.bestpractical.com/t/email-reply-to-ticket-creates-new-ticket-when-queue-name-contains-utf-8-character/35100" class="OWAAutoLink" id="LPlnk24262">https://forum.bestpractical.com/t/email-reply-to-ticket-creates-new-ticket-when-queue-name-contains-utf-8-character/35100</a><br>
</span></p>
</div>
</body>
</html>

Here’s reply, which should have been appended, but created new ticket instead:

Content-Language: sr-Latn-CS
X-RT-Incoming-Encryption: Not encrypted
X-MS-Exchange-Organization-Authmechanism: 04
X-MS-Tnef-Correlator: 
Date: Wed, 1 Jul 2020 21:42:41 +0200
X-MS-Exchange-Organization-Authas: Internal
X-MS-Has-Attach: 
Thread-Topic: [IT Podrška #13] AutoReply: Troubleshooting emails with knation
Received: from EXCHANGE.example.org [10.30.19.134] by apache.example.org with POP3 (fetchmail-6.4.8) for <fetchmail@localhost> (single-drop); Wed, 01 Jul 2020 21:45:24 +0200 (CEST)
Received: from EXCHANGE.example.org (10.30.19.134) by EXCHANGE.example.org (10.30.19.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.595.3 via Mailbox Transport; Wed, 1 Jul 2020 21:42:41 +0200
Received: from EXCHANGE.example.org (10.30.19.134) by EXCHANGE.example.org (10.30.19.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.595.3; Wed, 1 Jul 2020 21:42:41 +0200
Received: from EXCHANGE.example.org ([::1]) by EXCHANGE.example.org ([::1]) with mapi id 15.02.0595.003; Wed, 1 Jul 2020 21:42:41 +0200
References: <RT-Ticket-13@example.org> <3d458804d8fb48c998ffbad5aba59253@example.org>,<rt-4.4.4-16636-1593632237-1681.13-7-0@example.org>
In-Reply-To: <rt-4.4.4-16636-1593632237-1681.13-7-0@example.org>
To: "nIT Podrška" <nitpodrska@example.org>
Subject: Re: [IT Podrška #13] AutoReply: Troubleshooting emails with knation
Thread-Index: AQHWT95wTZrjTYtskkORNzAaKr9hgajy/MqAgAAilBo=
X-MS-Exchange-Organization-SCL: -1
MIME-Version: 1.0
X-MS-Exchange-Organization-Network-Message-ID: 03170a78-ee9c-4480-b2e5-08d81df6eac5
From: "Frljo Frljanović" <frljo.frljanovic@example.org>
content-type: text/html; charset="utf-8"
Message-ID: <ff1e195bb7c04f3eb1eeb2096af0e75b@example.org>
Content-Transfer-Encoding: quoted-printable
X-MS-Exchange-Organization-Authsource: EXCHANGE.example.org
X-MS-Exchange-Organization-Recordreviewcfmtype: 0
Accept-Language: sr-Latn-CS, sr-Latn-RS, en-US
X-RT-Original-Encoding: iso-8859-2
X-RT-Interface: Email
Content-Length: 734

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Helvetica,sans-serif;" dir="ltr">
<p></p>
<p style="font-family: Calibri, Helvetica, sans-serif; font-size: 16px;">This is reply to autoreply which should append to existing ticket (13) and not create a new one.</p>
<p></p>
<div style="color: rgb(0, 0, 0);">
<div>
<div id="divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p></p>
</div>
</div>
</div>
</div>
</body>
</html>

Also, think my path for overlay file is incorrect.

rt root on FreeBSD is in /usr/local/share/rt44/, while rt’s Email.pm file is in /usr/local/lib/perl5/site_perl/RT/Interface/Email.pm

I’m not sure what should be correct path for putting overlays in FreeBSD. Any ideas?

Ah okay I am able to duplicate! The issue was I didn’t set my SubjectTag for the queue to have some Polish characters. It looks like the subject tag is causing the issue, this seems like a bug

In the meantime I found the correct path for overlay. On FreeBSD it is:
/usr/local/share/rt44/lib/RT/Interface/Email_Local.pm

grepping rt.log for “Subject passed” now has hits:

[27171] [Wed Jul  1 20:35:46 2020] [error]: Subject passed: aj još jedan (/usr/local/share/rt44/lib/RT/Interface/Email_Local.pm:23)
[27177] [Wed Jul  1 20:38:50 2020] [error]: Subject passed: after the overlay (/usr/local/share/rt44/lib/RT/Interface/Email_Local.pm:23)
[27177] [Wed Jul  1 20:40:54 2020] [error]: Subject passed: Re: [IT Podrška #16] AutoReply: after the overlay (/usr/local/share/rt44/lib/RT/Interface/Email_Local.pm:23)

However, there aren’t any for “Found a ticket ID”.

Hope this helps with debugging. If there’s anything else I can do just send some instruction.

If you feel like trying, does adding this sub routine to the Email_Local.pm file do anything:

sub AddSubjectTag {
    my $subject = shift;
    my $ticket  = shift;
    unless ( ref $ticket ) {
        my $tmp = RT::Ticket->new( RT->SystemUser );
        $tmp->Load( $ticket );
        $ticket = $tmp;
    }
    my $id = $ticket->id;
    my $queue_tag = $ticket->QueueObj->SubjectTag;
    $queue_tag = Encode::encode( 'utf8', $queue_tag, Encode::FB_PERLQQ );

    my $tag_re = RT->Config->Get('EmailSubjectTagRegex');
    unless ( $tag_re ) {
        my $tag = $queue_tag || RT->Config->Get('rtname');
        $tag_re = qr/\Q$tag\E/;
    } elsif ( $queue_tag ) {
        $tag_re = qr/$tag_re|\Q$queue_tag\E/;
    }
    return $subject if $subject =~ /\[$tag_re\s+#$id\]/;

    $subject =~ s/(\r\n|\n|\s)/ /g;
    chomp $subject;
    return "[". ($queue_tag || RT->Config->Get('rtname')) ." #$id] $subject";
}

The change is adding:

$queue_tag = Encode::encode( 'utf8', $queue_tag, Encode::FB_PERLQQ );

To encode the subject tag with UTF8

Applying above results in appending ticket instead of creating new one. But there’s also downside of incorrectly displaying Queue name in email subject.

[IT PodrÅ¡ka #18] AutoReply: evo još jedan

… instead of

[IT Podrška #18] AutoReply: evo još jedan

OK that’s not all that surprising, it seems a better solution will need to be found with some more digging, At least you have a workaround by changing the subject tag value!

I think there’s something wrong here. First of all, I doubt the real reply had subject:

Subject: Re: [IT Podrška #13] AutoReply: Troubleshooting emails with knation

I would expect it to be encoded per RFC 2047:

Subject: Re: [IT =?UTF-8?Q?Podr=c5=a1ka?= #13] AutoReply: Troubleshooting emails with knation

Maybe the client is sending rfc6532 messages, but I find more likely that whatever was showing you the headers, automatically converted it.

Next, you would need to extract that from the header. I think that should be done in ExtractTicketId, probably at the $entity->head->get call. I have seen fully b64 subjects processed properly, so it is done.

sub ExtractTicketId {
    my $entity = shift;

    my $subject = Encode::decode( "UTF-8", $entity->head->get('Subject') || '' );
    chomp $subject;
    return ParseTicketId( $subject, $entity );
}

You can print it, if you want.

Now, you want this to match. You may think you are doing:

    "[IT Podrška #4]") =~ qr/\[\QIT Podrška\E\s+\#/i

However, what you are doing is actually more like:

     Encode::decode( "UTF-8", "[IT Podrška #4]") =~ qr/\[\QIT Podrška\E\s+\#/iU

which won’t work
(test with perl -e 'use strict; use warnings; use Encode; print Encode::decode( "UTF-8", "[IT Podrška #4]") =~ qr/\[\QIT Podrška\E\s+\#/i ? "yes\n" : "no\n";)

You actually want to end up with a command like:

perl -e 'use strict; use warnings; use Encode; my $test = Encode::decode("UTF-8", "\QIT Podrška"); print Encode::decode( "UTF-8", "[IT Podrška #4]") =~ qr/\[$test\E\s+\#/i ? "yes\n" : "no\n";'

The good news is that you don’t need to overlay ParseTicketId, you can achieve this simply by setting EmailSubjectTagRegex properly (btw, I would additionally accept both “IT Podrška” and “IT Podrska”).