@Test void testCreateMimeMessageFromPreDefinedMessage() throws Exception { JavaMailSender mailSender = new SimpleEmailServiceJavaMailSender(null); MimeMessage original = createMimeMessage(); MimeMessage mimeMessage = mailSender.createMimeMessage( new ByteArrayInputStream(getMimeMessageAsByteArray(original))); assertThat(mimeMessage).isNotNull(); assertThat(mimeMessage.getSubject()).isEqualTo(original.getSubject()); assertThat(mimeMessage.getContent()).isEqualTo(original.getContent()); assertThat(mimeMessage.getRecipients(Message.RecipientType.TO)[0]) .isEqualTo(original.getRecipients(Message.RecipientType.TO)[0]); }
@Override public MimeMessage createMimeMessage() { if (ClassUtils.isPresent(SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader())) { Class<?> smartMimeMessage = ClassUtils.resolveClassName( SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader()); Constructor<?> constructor = ClassUtils.getConstructorIfAvailable( smartMimeMessage, Session.class, String.class, FileTypeMap.class); if (constructor != null) { Object mimeMessage = BeanUtils.instantiateClass(constructor, getSession(), this.defaultEncoding, this.defaultFileTypeMap); return (MimeMessage) mimeMessage; } } return new MimeMessage(getSession()); }
SimpleEmailServiceJavaMailSender extends SimpleEmailServiceMailSender implements JavaMailSender { @Override public MimeMessage createMimeMessage() { if (ClassUtils.isPresent(SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader())) { Class<?> smartMimeMessage = ClassUtils.resolveClassName( SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader()); Constructor<?> constructor = ClassUtils.getConstructorIfAvailable( smartMimeMessage, Session.class, String.class, FileTypeMap.class); if (constructor != null) { Object mimeMessage = BeanUtils.instantiateClass(constructor, getSession(), this.defaultEncoding, this.defaultFileTypeMap); return (MimeMessage) mimeMessage; } } return new MimeMessage(getSession()); } }
SimpleEmailServiceJavaMailSender extends SimpleEmailServiceMailSender implements JavaMailSender { @Override public MimeMessage createMimeMessage() { if (ClassUtils.isPresent(SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader())) { Class<?> smartMimeMessage = ClassUtils.resolveClassName( SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader()); Constructor<?> constructor = ClassUtils.getConstructorIfAvailable( smartMimeMessage, Session.class, String.class, FileTypeMap.class); if (constructor != null) { Object mimeMessage = BeanUtils.instantiateClass(constructor, getSession(), this.defaultEncoding, this.defaultFileTypeMap); return (MimeMessage) mimeMessage; } } return new MimeMessage(getSession()); } SimpleEmailServiceJavaMailSender(
			AmazonSimpleEmailService amazonSimpleEmailService); }
SimpleEmailServiceJavaMailSender extends SimpleEmailServiceMailSender implements JavaMailSender { @Override public MimeMessage createMimeMessage() { if (ClassUtils.isPresent(SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader())) { Class<?> smartMimeMessage = ClassUtils.resolveClassName( SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader()); Constructor<?> constructor = ClassUtils.getConstructorIfAvailable( smartMimeMessage, Session.class, String.class, FileTypeMap.class); if (constructor != null) { Object mimeMessage = BeanUtils.instantiateClass(constructor, getSession(), this.defaultEncoding, this.defaultFileTypeMap); return (MimeMessage) mimeMessage; } } return new MimeMessage(getSession()); } SimpleEmailServiceJavaMailSender(
			AmazonSimpleEmailService amazonSimpleEmailService); void setJavaMailProperties(Properties javaMailProperties); void setSession(Session session); void setDefaultEncoding(String defaultEncoding); void setDefaultFileTypeMap(FileTypeMap defaultFileTypeMap); @Override MimeMessage createMimeMessage(); @Override MimeMessage createMimeMessage(InputStream contentStream); @Override void send(MimeMessage mimeMessage); @SuppressWarnings("OverloadedVarargsMethod") @Override void send(MimeMessage... mimeMessages); @Override void send(MimeMessagePreparator mimeMessagePreparator); @SuppressWarnings("OverloadedVarargsMethod") @Override void send(MimeMessagePreparator... mimeMessagePreparators); }
SimpleEmailServiceJavaMailSender extends SimpleEmailServiceMailSender implements JavaMailSender { @Override public MimeMessage createMimeMessage() { if (ClassUtils.isPresent(SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader())) { Class<?> smartMimeMessage = ClassUtils.resolveClassName( SMART_MIME_MESSAGE_CLASS_NAME, ClassUtils.getDefaultClassLoader()); Constructor<?> constructor = ClassUtils.getConstructorIfAvailable( smartMimeMessage, Session.class, String.class, FileTypeMap.class); if (constructor != null) { Object mimeMessage = BeanUtils.instantiateClass(constructor, getSession(), this.defaultEncoding, this.defaultFileTypeMap); return (MimeMessage) mimeMessage; } } return new MimeMessage(getSession()); } SimpleEmailServiceJavaMailSender(
			AmazonSimpleEmailService amazonSimpleEmailService); void setJavaMailProperties(Properties javaMailProperties); void setSession(Session session); void setDefaultEncoding(String defaultEncoding); void setDefaultFileTypeMap(FileTypeMap defaultFileTypeMap); @Override MimeMessage createMimeMessage(); @Override MimeMessage createMimeMessage(InputStream contentStream); @Override void send(MimeMessage mimeMessage); @SuppressWarnings("OverloadedVarargsMethod") @Override void send(MimeMessage... mimeMessages); @Override void send(MimeMessagePreparator mimeMessagePreparator); @SuppressWarnings("OverloadedVarargsMethod") @Override void send(MimeMessagePreparator... mimeMessagePreparators);  }