Hi SpringBoot mail, I have a Spring application that sends an email. With SpringBoot 2.7.14 it works fine. When I change to SpringBoot3+ I get this error.
Class com.sun.mail.util.LineInputStream does not implement the requested interface jakarta.mail.util.LineInputStream.
Below is the code snippet I use. Thanx
import jakarta.activation.DataHandler;
import jakarta.activation.DataSource;
import jakarta.activation.FileDataSource;
import jakarta.mail.BodyPart;
import jakarta.mail.MessagingException;
import jakarta.mail.internet.MimeBodyPart;
import jakarta.mail.internet.MimeMessage;
import jakarta.mail.internet.MimeMultipart;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.InputStreamSource;
import org.springframework.core.io.Resource;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context;
final Context context = new Context();
setBasics(context, String.format("%s %s", account.getLastName(), account.getFirstName()), account.getProfileUrl());
final String text = templateEngine.process(ACCOUNT_UPDATE_TEMPLATE, context);
final MimeMessage message = getMimeMessage();
final MimeMessageHelper helper = new MimeMessageHelper(message, true, UTF_8_ENCODING);
helper.setPriority(1);
helper.setSubject("New Account");
helper.setFrom(fromEmail);
helper.setTo(account.getEmail());
helper.setText(text, true);
// Add the inline image, referenced from the HTML code as "cid:${logo}"
final InputStreamSource imageSource = new ClassPathResource("static/images/logo.png");
helper.addInline(IMAGE_LOGO, imageSource, IMAGE_CONTENT_TYPE);
emailSender.send(message);
Hi SpringBoot mail, I have a Spring application that sends an email. With SpringBoot 2.7.14 it works fine. When I change to SpringBoot3+ I get this error.
Class com.sun.mail.util.LineInputStream does not implement the requested interface jakarta.mail.util.LineInputStream.
Below is the code snippet I use. Thanx