@Test public void isMdnSentAutomaticallyShouldNotThrowOnBodyPartsWithManyLines() throws Exception { int mime4jDefaultMaxHeaderCount = 1000; int headerCount = mime4jDefaultMaxHeaderCount + 10; MimeMessageBuilder message = MimeMessageBuilder.mimeMessageBuilder() .addHeaders() .setMultipartWithBodyParts(MimeMessageBuilder.bodyPartBuilder() .addHeaders(Collections.nCopies(headerCount, new MimeMessageBuilder.Header("name", "value"))) .data("The body part have 1010 headers, which overpass MIME4J default limits")); FakeMail fakeMail = FakeMail.builder() .name("mail") .sender(MailAddressFixture.ANY_AT_JAMES) .mimeMessage(message) .build(); assertThat(new AutomaticallySentMailDetectorImpl().isMdnSentAutomatically(fakeMail)).isFalse(); }
@Override public boolean isMdnSentAutomatically(Mail mail) throws MessagingException { ResultCollector resultCollector = new ResultCollector(false); MimeStreamParser parser = new MimeStreamParser(MimeConfig.custom() .setMaxContentLen(100 * 1024 * 1024) .setMaxHeaderCount(-1) .setMaxHeaderLen(-1) .setMaxLineLen(-1) .setHeadlessParsing(mail.getMessage().getContentType()) .build()); parser.setContentHandler(createMdnContentHandler(resultCollector)); try { parser.parse(new MimeMessageInputStream(mail.getMessage())); } catch (MimeException e) { throw new MessagingException("Can not parse Mime", e); } catch (IOException e) { throw new MessagingException("Can not read content", e); } return resultCollector.getResult(); }
AutomaticallySentMailDetectorImpl implements AutomaticallySentMailDetector { @Override public boolean isMdnSentAutomatically(Mail mail) throws MessagingException { ResultCollector resultCollector = new ResultCollector(false); MimeStreamParser parser = new MimeStreamParser(MimeConfig.custom() .setMaxContentLen(100 * 1024 * 1024) .setMaxHeaderCount(-1) .setMaxHeaderLen(-1) .setMaxLineLen(-1) .setHeadlessParsing(mail.getMessage().getContentType()) .build()); parser.setContentHandler(createMdnContentHandler(resultCollector)); try { parser.parse(new MimeMessageInputStream(mail.getMessage())); } catch (MimeException e) { throw new MessagingException("Can not parse Mime", e); } catch (IOException e) { throw new MessagingException("Can not read content", e); } return resultCollector.getResult(); } }
AutomaticallySentMailDetectorImpl implements AutomaticallySentMailDetector { @Override public boolean isMdnSentAutomatically(Mail mail) throws MessagingException { ResultCollector resultCollector = new ResultCollector(false); MimeStreamParser parser = new MimeStreamParser(MimeConfig.custom() .setMaxContentLen(100 * 1024 * 1024) .setMaxHeaderCount(-1) .setMaxHeaderLen(-1) .setMaxLineLen(-1) .setHeadlessParsing(mail.getMessage().getContentType()) .build()); parser.setContentHandler(createMdnContentHandler(resultCollector)); try { parser.parse(new MimeMessageInputStream(mail.getMessage())); } catch (MimeException e) { throw new MessagingException("Can not parse Mime", e); } catch (IOException e) { throw new MessagingException("Can not read content", e); } return resultCollector.getResult(); }  }
AutomaticallySentMailDetectorImpl implements AutomaticallySentMailDetector { @Override public boolean isMdnSentAutomatically(Mail mail) throws MessagingException { ResultCollector resultCollector = new ResultCollector(false); MimeStreamParser parser = new MimeStreamParser(MimeConfig.custom() .setMaxContentLen(100 * 1024 * 1024) .setMaxHeaderCount(-1) .setMaxHeaderLen(-1) .setMaxLineLen(-1) .setHeadlessParsing(mail.getMessage().getContentType()) .build()); parser.setContentHandler(createMdnContentHandler(resultCollector)); try { parser.parse(new MimeMessageInputStream(mail.getMessage())); } catch (MimeException e) { throw new MessagingException("Can not parse Mime", e); } catch (IOException e) { throw new MessagingException("Can not read content", e); } return resultCollector.getResult(); }  @Override boolean isAutomaticallySent(Mail mail); @Override boolean isMailingList(Mail mail); @Override boolean isAutoSubmitted(Mail mail); @Override boolean isMdnSentAutomatically(Mail mail); }
AutomaticallySentMailDetectorImpl implements AutomaticallySentMailDetector { @Override public boolean isMdnSentAutomatically(Mail mail) throws MessagingException { ResultCollector resultCollector = new ResultCollector(false); MimeStreamParser parser = new MimeStreamParser(MimeConfig.custom() .setMaxContentLen(100 * 1024 * 1024) .setMaxHeaderCount(-1) .setMaxHeaderLen(-1) .setMaxLineLen(-1) .setHeadlessParsing(mail.getMessage().getContentType()) .build()); parser.setContentHandler(createMdnContentHandler(resultCollector)); try { parser.parse(new MimeMessageInputStream(mail.getMessage())); } catch (MimeException e) { throw new MessagingException("Can not parse Mime", e); } catch (IOException e) { throw new MessagingException("Can not read content", e); } return resultCollector.getResult(); }  @Override boolean isAutomaticallySent(Mail mail); @Override boolean isMailingList(Mail mail); @Override boolean isAutoSubmitted(Mail mail); @Override boolean isMdnSentAutomatically(Mail mail);  }