@Test public void sendTextMessage() throws MessagingException { SimpleMailMessage message = new SimpleMailMessage(); message.setFrom("test@sender.com"); wonEmailSender.sendTextMessage("test@receiver.com", "test subject", "test message"); Message[] messages = testSmtp.getReceivedMessages(); Assert.assertTrue(messages.length == 1); Assert.assertEquals("test subject", messages[0].getSubject()); String body = GreenMailUtil.getBody(messages[0]).replaceAll("=\r?\n", ""); Assert.assertEquals("test message", body); }
public void sendTextMessage(String toEmail, String subject, String text) { SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setSubject(subject); msg.setTo(toEmail); msg.setText(text); try { mailSender.send(msg); } catch (MailException ex) { logger.warn(ex.getMessage()); } }
WonMailSender { public void sendTextMessage(String toEmail, String subject, String text) { SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setSubject(subject); msg.setTo(toEmail); msg.setText(text); try { mailSender.send(msg); } catch (MailException ex) { logger.warn(ex.getMessage()); } } }
WonMailSender { public void sendTextMessage(String toEmail, String subject, String text) { SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setSubject(subject); msg.setTo(toEmail); msg.setText(text); try { mailSender.send(msg); } catch (MailException ex) { logger.warn(ex.getMessage()); } }  }
WonMailSender { public void sendTextMessage(String toEmail, String subject, String text) { SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setSubject(subject); msg.setTo(toEmail); msg.setText(text); try { mailSender.send(msg); } catch (MailException ex) { logger.warn(ex.getMessage()); } }  void setMailSender(JavaMailSender mailSender); void setTemplateMessage(SimpleMailMessage templateMessage); void sendTextMessage(String toEmail, String subject, String text); void sendHtmlMessage(String toEmail, String subject, String htmlBody); void sendFileMessage(String toEmail, String subject, String body, String fileName, File file); }
WonMailSender { public void sendTextMessage(String toEmail, String subject, String text) { SimpleMailMessage msg = new SimpleMailMessage(this.templateMessage); msg.setSubject(subject); msg.setTo(toEmail); msg.setText(text); try { mailSender.send(msg); } catch (MailException ex) { logger.warn(ex.getMessage()); } }  void setMailSender(JavaMailSender mailSender); void setTemplateMessage(SimpleMailMessage templateMessage); void sendTextMessage(String toEmail, String subject, String text); void sendHtmlMessage(String toEmail, String subject, String htmlBody); void sendFileMessage(String toEmail, String subject, String body, String fileName, File file);  }