Unable to create attachment with Email attribute = HTML

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

Moderators: Developer, Contributor

SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Unable to create attachment with Email attribute = HTML

Post by SL-Gundam »

So the attachments are added correctly but we have 1 out of 2 where the attachments and notes are split into 2 parts.

It probably happened because your webserver took longer to process the request and the timestamps were too far apart for the note and the attachments to be merged

I have a solution for this: https://github.com/mantisbt-plugins/Ema ... 1602907c3d

Please test
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Unable to create attachment with Email attribute = HTML

Post by SL-Gundam »

If your webserver takes exceptionally long to process a request it's even possible that the note gets added but the attachment does not. This is because attachments are generally bigger and therefore require more processing power
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

Thanks SL-Gundam

applying latest fixes on mail_api.php seems working after sending 2 emails. changelog also updated for future reference

core/mail_api.php
doc/CHANGELOG.txt

will continue with some regression and update accordingly. many thanks
Attachments
test4-C.JPG
test4-C.JPG (70.68 KiB) Viewed 13004 times
test3-C.JPG
test3-C.JPG (67.26 KiB) Viewed 13004 times
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

SL-Gundam,

Previous issue seemed OK. But now, new symptom observed. Looks the email cannot be parsed accordingly hence not able to create note with the latest reply. Refer attachments.
Attachments
Test5-A.JPG
Test5-A.JPG (47.31 KiB) Viewed 12989 times
test5-raw_msg_shared.txt
(14.74 KiB) Downloaded 999 times
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Unable to create attachment with Email attribute = HTML

Post by SL-Gundam »

I think i've found the reason
Your mail client for test 1 and test 2 handle the from-sent-to-subject part a little bit differently (see below)
What mail client are you using?
The ** around it makes MantisBT show that text in bold. EmailReplyParser does not like that because it does not expect it.

We have 2 options.
1. Find out the idiosyncrasy in your mail client and see what we can do to deal with it
2. Turn off markdown support in MantisBT. EmailReporting will then convert HTML to plaintext instead of Markdown and therefore this will not be an issue

Code: Select all

Html on. Test 2. Reply email

 

**From:** Mohammad Zairi Othman
**Sent:** Saturday, 2 May, 2020 9:48 PM
**To:** ticket.mantis
**Subject:** RE: [## ITSM ## BAU Issues 2020 0002808]: Create ticket and note

 

Html on. Test 1. Reply email

 

\-----Original Message\-----
From: ticket.mantis@muamalat.com.my [mailto:ticket.mantis@muamalat.com.my]
Sent: Saturday, 2 May, 2020 9:47 PM
To: Mohammad Zairi Othman
Subject: [## ITSM ## BAU Issues 2020 0002808]: Create ticket and note
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

Outlook 2010.

Let me try to find out the idiosyncrasy by trying other email client.
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

Just to update, option 2 not an options because the result was messy. whole chunk of xmls were put in the note
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Unable to create attachment with Email attribute = HTML

Post by SL-Gundam »

If markdown is not a big requirement for you we can try to work on a better html -> plaintext conversion
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

i'm ok with that. while at the same time, im suspecting this has to do with Exchange server and checking on it
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Unable to create attachment with Email attribute = HTML

Post by SL-Gundam »

If you are running on-premise Exchange it might be best to look at this:
https://www.mantisbt.org/wiki/doku.php/ ... parse_html

There is a note here for Exchange users and 2 links to Microsoft help.
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

Thanks SL-Gundam. Will take a look

Any dirty code idea that I can apply to strip the ** sign at from-sent-to-subject?
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

SL-Gundam,

Update:

These were my setup on the reply. However, not satisfactory. Refer attached

Html on
Markdown off
Imap html & alternative text
Debug on
Attachments
06052020 Capture.JPG
06052020 Capture.JPG (62.37 KiB) Viewed 12811 times
raw_msg_06052020.txt
(29.41 KiB) Downloaded 1032 times
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

SL-Gundam

I think i understood the flow and reason for such behavior.

It was because, I'm replying to my own reply instead of replying to mantis's notification email. In mantis's notification, there's a string "-----Original Message-----" that I believed parser use to identify the start of a reply. Similar to mail_remove_replies_after, I guess

So wild idea for scenario "replying to mail/reply other than Mantis notification email", is there possibility for you to default/create default element in the array for " "-----Original Message-----"" on top for From element or something like that which I think by doing so, parser should be able to parser > create note accordingly.

This would benefit for environment that email is constantly use for communication while at the same time those email's communication would be capture accordingly in the respective mantis ticket by creating note accordingly.

just to my cent.
SL-Gundam
Posts: 722
Joined: 06 Jul 2011, 14:17

Re: Unable to create attachment with Email attribute = HTML

Post by SL-Gundam »

If you are running the latest 0.11.0-DEV EmailReplyParser should look for the "from" line and set that as the start of a reply.
It expects the from line to look like this: "From: NAME <EMAIL>"

Your from lines are only showing the name, no email address

"-----Original Message-----" are usually added only for plaintext emails. MantisBT notification are plaintext so any replies on those emails are usually in plaintext aswell
sintaq
Posts: 70
Joined: 12 Oct 2017, 11:38

Re: Unable to create attachment with Email attribute = HTML

Post by sintaq »

SL- Gundam,

Thanks for your clarification. Finally, I'm able to get things working with last hiccup (so far) :lol:

Now, mantis able to parse the email correctly. however, it will re-add images pasted in previous email. flow like this,

1) send first html email with attachment and image pasted on it
2) send second html email with no attachment and image > mantis able able to parse 2nd email accordingly however when creating note, image from first email for added as well.
Attachments
Reply30-Outlook screenshot.JPG
Reply30-Outlook screenshot.JPG (43.86 KiB) Viewed 12725 times
Reply30-Mantis screenshot.JPG
Reply30-Mantis screenshot.JPG (37.91 KiB) Viewed 12726 times
Post Reply