From 7ffa347900fbb24799153624526e3d0e9ff8517a Mon Sep 17 00:00:00 2001 From: peccu Date: Wed, 14 Mar 2018 14:34:39 +0900 Subject: [PATCH] support multipart/mixed Loop when content has nested multipart. Thanks to https://stackoverflow.com/a/27575671/514411 --- .../com/mockmock/mail/MockMockMessageHandlerFactory.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/com/mockmock/mail/MockMockMessageHandlerFactory.java b/src/main/java/com/mockmock/mail/MockMockMessageHandlerFactory.java index 62ce824..2ffbb23 100644 --- a/src/main/java/com/mockmock/mail/MockMockMessageHandlerFactory.java +++ b/src/main/java/com/mockmock/mail/MockMockMessageHandlerFactory.java @@ -134,6 +134,14 @@ else if(contentType.matches("text/html.*")) { mockMail.setBodyHtml(convertStreamToString(bodyPart.getInputStream())); } + else if(contentType.contains("multipart")) + { + // Loop if the content type is multipart then get the content that is in that part, + // make it the new container and restart the loop in that part of the message. + multipart = (Multipart)bodyPart.getContent(); + i = -1; + continue; + } } } else if(messageContent instanceof InputStream)