@Test public void isMdnSentAutomaticallyShouldNotFilterManuallySentMdn() throws Exception { MimeMessage message = MimeMessageUtil.defaultMimeMessage(); MimeMultipart multipart = new MimeMultipart(); MimeBodyPart scriptPart = new MimeBodyPart(); scriptPart.setDataHandler( new DataHandler( new ByteArrayDataSource( Joiner.on("\r\n").join( "Final-Recipient: rfc822;any@any.com", "Disposition: manual-action/MDN-sent-manually; displayed", ""), "message/disposition-notification; charset=UTF-8") )); scriptPart.setHeader("Content-Type", "message/disposition-notification"); multipart.addBodyPart(scriptPart); message.setContent(multipart); message.saveChanges(); FakeMail fakeMail = FakeMail.builder() .name("mail") .sender("any@any.com") .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);  }