@Test public void sendMailWithoutTemplate() throws MessagingException, IOException { final Email email = getSimpleMail(); assertThat(email.getSentAt(), is(nullValue())); final MimeMessage sentMessage = mailService.send(email); assertThat(email.getSentAt(), not(is(nullValue()))); validateFrom(email, sentMessage); validateReplyTo(email, sentMessage); validateTo(email, sentMessage); validateCc(email, sentMessage); validateBcc(email, sentMessage); validateSubject(email, sentMessage); validateBody(email, sentMessage); verify(javaMailSender, times(1)).createMimeMessage(); verify(javaMailSender, times(1)).send(any(MimeMessage.class)); }
@Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; }
DefaultEmailService implements EmailService { @Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; } }
DefaultEmailService implements EmailService { @Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; } @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final TemplateService templateService,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); }
DefaultEmailService implements EmailService { @Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; } @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final TemplateService templateService,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Override MimeMessage send(final @NonNull Email email); MimeMessage send(final @NonNull Email email,
                            final @NonNull String template,
                            final Map<String, Object> modelObject,
                            final @NonNull InlinePicture... inlinePictures); }
DefaultEmailService implements EmailService { @Override public MimeMessage send(final @NonNull Email email) { email.setSentAt(new Date()); final MimeMessage mimeMessage = toMimeMessage(email); javaMailSender.send(mimeMessage); emailLogRenderer.info("Sent email {}.", email); return mimeMessage; } @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final TemplateService templateService,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Autowired(required = false)  DefaultEmailService(final @NonNull JavaMailSender javaMailSender,
                               final @NonNull EmailToMimeMessage emailToMimeMessage,
                               final @NonNull EmailLogRenderer emailLogRenderer); @Override MimeMessage send(final @NonNull Email email); MimeMessage send(final @NonNull Email email,
                            final @NonNull String template,
                            final Map<String, Object> modelObject,
                            final @NonNull InlinePicture... inlinePictures);  }