### Question:
PostmanMail implements Postman { @Override public void send(ILoggingEvent event) { Session session = initSession(); MimeMessage message = new MimeMessage(session); try { message.setFrom(new InternetAddress(from)); for (String to : allTo) message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject(firstEventSubjectPatternLayout.doLayout(event)); String logRow = "<span style=\"display: block; width: 20px; background-color: red; color: white; font-weight: bold;\">&nbsp;E&nbsp;</span> " + event.getFormattedMessage() + "<br/>"; Map<String, Object> scopes = new HashMap<String, Object>(); scopes.put("logRow", logRow); MustacheFactory mustacheFactory = new DefaultMustacheFactory(); Mustache mustache = mustacheFactory.compile(new StringReader(firstEventBodyTemplate), "postmanMail-single"); StringWriter writer = new StringWriter(); mustache.execute(writer, scopes); writer.flush(); String text = StringEscapeUtils.unescapeHtml4(writer.toString()); System.out.println("text: " + text); message.setContent(text, "text/html; charset=utf-8"); Transport.send(message); System.err.println("Sent message successfully...."); } catch (AddressException e) { throw new RuntimeException("unexpected behavior", e); } catch (MessagingException e) { throw new RuntimeException("unexpected behavior", e); } } PostmanMail(String smtpHost, int smtpPort, boolean ssl, String username, String password, String from, List<String> allTo, Layout<ILoggingEvent> firstEventSubjectPatternLayout, String firstEventBodyTemplate); @Override void send(ILoggingEvent event); @Override void send(List<ILoggingEvent> events);  }### Answer:
@Test public void sendOneMail() { smtpServer = SimpleSmtpServer.start(SMTP_PORT); context.checking(new Expectations() {{ oneOf(layout).doLayout(with(any(ILoggingEvent.class))); }}); PostmanMail postman = new PostmanMail("localhost", SMTP_PORT, false, null, null, "me@localhost", asList("you@localhost"), layout, ""); postman.send(new LoggingEvent()); assertEquals(1, smtpServer.getReceivedEmailSize()); smtpServer.stop(); }