Help with customer suport use case: how to reply to created tickets?

This plugin allows you to report an issue in MantisBT by sending an email to a particular mail account

Moderators: Developer, Contributor

seanm
Posts: 16
Joined: 06 Jan 2021, 22:34

Re: Help with customer suport use case: how to reply to created tickets?

Post by seanm »

So I've confirmed what's happening.

The parse_from_field() function uses the following regex:

/^(?:(?P<name>.*)<|)(?P<email>(?P<local>[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+)@(?P<domain>[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*))(?:>|)$/u

against a "From:" field of:

"First Last" <name@example.com> (by way Foo Bar <foobar@company.com>)

And it doesn't match the regex. You can experiment with it here: https://regexr.com/5msr7

It then stores the raw "From:" field as the 'email' key:

'email' => $p_from_address,

This I think is a mistake. From its name and usage, the 'email' key is expected to be an email address, but a "From:" field is not guaranteed to be an exact format and as you see above can even contain two email addresses within it. I think setting null would make more sense in this branch. I'll try to create and test a patch...
SL-Gundam
Posts: 664
Joined: 06 Jul 2011, 14:17

Re: Help with customer suport use case: how to reply to created tickets?

Post by SL-Gundam »

It matches properly when its ""First Last" <name@example.com>" the part after that is the issue.
It's not a situation we've ever had to deal with. But yes we need to make sure EmailReporting handles it properly.
Exchange does something similar i believe. I'll check that line to make sure we cover it properly
seanm
Posts: 16
Joined: 06 Jan 2021, 22:34

Re: Help with customer suport use case: how to reply to created tickets?

Post by seanm »

That worked, thanks!
seanm
Posts: 16
Joined: 06 Jan 2021, 22:34

Re: Help with customer suport use case: how to reply to created tickets?

Post by seanm »

So this has all been working pretty well for me for a few weeks now, but just spotted a case of an email reply getting attached to the wrong ticket in mantis. How do I troubleshoot that? Upon examining a new email, how does it decide which existing ticket (if any) to attach it to? Does it look at the "In-Reply-To:" header? The "Subject:" header? Some combination?
SL-Gundam
Posts: 664
Joined: 06 Jul 2011, 14:17

Re: Help with customer suport use case: how to reply to created tickets?

Post by SL-Gundam »

It depends on what options you have enabled

The subject line takes precedence over message-id

What kind of search should be used to find the issue id in the subject
Use Message-ID in Mail header to identify notes
seanm
Posts: 16
Joined: 06 Jan 2021, 22:34

Re: Help with customer suport use case: how to reply to created tickets?

Post by seanm »

I have those two settings as 'strict' and 'yes', respectively.

The first email in the thread was titled "Problème avec la mise à jour à l'Université Laval". It created ticket 11183. My boss replied, and that got attached to 11183. The customer replied twice, and both those emails got attached. My boss replied again, and it was also attached. That email was
"Message-Id: <D7487533-3AF3-4A75-AAA1-E703DBFAF233@example.com>".

Perfect so far.

Then I replied to my boss's last email, but my reply got attached to ticket 10843, which has an entirely different subject and involves totally different people. My email had in its headers: "In-Reply-To: <D7487533-3AF3-4A75-AAA1-E703DBFAF233@example.com>" The only thing slightly different about my email was that I dropped the customer from CC because I was making a comment just for coworkers.
SL-Gundam
Posts: 664
Joined: 06 Jul 2011, 14:17

Re: Help with customer suport use case: how to reply to created tickets?

Post by SL-Gundam »

That is weird.
An email keeps track of all the previous message id's. EmailReporting will check all of them. Not just the last one.
seanm
Posts: 16
Joined: 06 Jan 2021, 22:34

Re: Help with customer suport use case: how to reply to created tickets?

Post by seanm »

We've just found a second occurrence, so it's probably not cosmic rays. :)

If it would help, and if you're willing, I can share the full headers of the emails that got misfiled. But not on this public forum. I could email you at the address you make your git commits from, if that's ok with you?
SL-Gundam
Posts: 664
Joined: 06 Jul 2011, 14:17

Re: Help with customer suport use case: how to reply to created tickets?

Post by SL-Gundam »

The second one is obvious. The first one I've got some suspicions but nothing conclusive.
EmailReporting keeps a database with the message id's and the issue id's that they belong to.
If somebody replies to your email that was mapped to issue 10843 any subsequent emails will be mapped to that ID as well. So ones it goes wrong it will not stop with one email.

Here's what i need to debug this
The contents of the table "mantis_plugin_EmailReporting_msgids_table"
I will also need all raw_msg files concerning issues 11183 and 10843. It would help if you mark which issue they should have been mapped to and which issue they were actually mapped to.

You can send them to the email address from my git commits
Post Reply