Email sending as HTML format

Jmix version: 2.2.3
Jmix Studio plugin version: 2.2.4-241
IntelliJ IDEA 2024.1 (Ultimate Edition)

Hi Jmix team.

I’ve encountered problem with HTML format of email template. That is to say,
image
such kind of email I received.

        String body = resources.getResourceAsString("template/email.html");
        EmailInfo emailInfo = EmailInfoBuilder.create()
                .setAddresses(tempUser.getEmail())
                .setSubject("IOT Radiomer")
                .setBody(body)
                .build();
        try {
            emailer.sendEmail(emailInfo);
            return true;
        } catch (Exception e) {
            log.warn("EmailService.sendEmail: {}", e.getMessage());
        }

So, can you provide any solution to send email as a HTML format?

Try to set bodyContentType as "text/html; charset=UTF-8". Or remove first string <!Doctype html> from body. becouse Emailer checks if body starts with "<html>"

3 Likes

Thanks, It works for me