}
}
Map<String,Object> context = newHashMap(options.getContext());
context.put("toFullName", toName);
Email email = new SimpleEmail();
try
{
email.setHostName("localhost");
email.setSmtpPort(2525);
email.setFrom(options.getFromEmail(), options.getFromName());
email.setSubject("[test] " + render(options.getSubjectTemplate(), context));
email.setMsg(render(options.getBodyTemplate(), context));
email.addTo(toEmail);
if (options.getReplyToEmail() != null)
{
email.setReplyTo(Arrays.asList(new InternetAddress(options.getReplyToEmail())));
}
email.send();
}
catch (EmailException e)
{
log.error("Unable to send email", e);
if (log.isDebugEnabled())
{
ByteArrayOutputStream bout = new ByteArrayOutputStream();
try
{
email.getMimeMessage().writeTo(bout);
log.debug("Sent email:\n" + new String(bout.toByteArray()));
}
catch (MessagingException ex)
{
throw new RuntimeException(ex);