camunda-community-hub / camunda-platform-7-mail

Mail connectors for Camunda Platform 7
Apache License 2.0
84 stars 73 forks source link

Support multipart/mixed and multipart/alternative + nested parts #11

Open vanderstaaij opened 7 years ago

vanderstaaij commented 7 years ago

Hi there,

In some of the emails we receive, the messages are a combination of multipart/mixed and multipart/alternative parts. E.g.:

From: xxxx <xxxx@xxxx.nl>
Date: Wed, 15 Nov 2017 07:49:37 +0100
Subject: xxxx
To: xxxx@xxxx.nl
Content-Type: multipart/mixed; boundary="001a1147380449a331055dffe87c"

--001a1147380449a331055dffe87c
Content-Type: multipart/alternative; boundary="001a1147380449a32d055dffe87a"

--001a1147380449a32d055dffe87a
Content-Type: text/plain; charset="UTF-8"

Message plain text

--001a1147380449a32d055dffe87a
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<p>Message HTML</p>

--001a1147380449a32d055dffe87a--
--001a1147380449a331055dffe87c
Content-Type: application/pdf; name="xxxx.pdf"
Content-Disposition: attachment; filename="xxxx.pdf"
Content-Transfer-Encoding: base64
X-Attachment-Id: ab0f0569c61ec80c_0.1

--001a1147380449a331055dffe87c--

When extracting e.g. mail.getText() or mail.getHTML() for these messages I get null as result.

Can this please be supported?

Kind regards, Eric

saig0 commented 7 years ago

Hi Eric,

thank you for reaching this out. Do you want to implement this feature and create a pull request?

Best regards, Philipp

vanderstaaij commented 7 years ago

Well, I am not a Java developer :) There is a big chance I might screw up implementing a new feature. I'm just using your extension in Camunda and I noticed this happening with nested multipart messages.

I've been digging a bit though. Found this StackOverflow question: https://stackoverflow.com/questions/13331989/how-to-handle-multipart-alternative-mail-with-javamail

I understand that iterating/recursing over all (nested) parts of a multipart mail is quite complicated as there are so many possibilities. So I think it is better to leave it to the pros.

saig0 commented 7 years ago

Ok, Eric :smile:

But it can take a while until I've time to implement this feature. However, I take it on the agenda.

Maybe someone else wants to work on this?

vanderstaaij commented 7 years ago

Would be great. Thanks!