@Async
public void sendEmail(String to, String subject, WebContext context,String template) throws MessagingException
{
MimeMessage mimeMessage = mailSender.createMimeMessage();
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage, false, "utf-8");
helper.setTo(to);
helper.setFrom("some.email@mail-server.com");
helper.setSubject(subject);
System.out.println("content1"); //able to see this in console
String content=templateEngine.process(template, context); //problem with this
System.out.println("content2"); // not able to see this in console
helper.setText(content, true);
mailSender.send(mimeMessage);
}
I could not send email with @Async
annotation. when I remove this annotation, email works. @Async
is not working with Thymeleaf template engine. I placed @EnableAsync
on RootConfig
, where I am creating beans
Any ideas?