我正在使用此处找到的 Ozimov Spring Boot 电子邮件工具
非常容易使用:
@Service
public class TestService {
@Autowired
private EmailService emailService;
public void sendEmail() throws UnsupportedEncodingException {
final Email email = DefaultEmail.builder()
.from(new InternetAddress("hari.seldon@the-foundation.gal",
"Hari Seldon"))
.to(newArrayList(
new InternetAddress("the-real-cleon@trantor.gov",
"Cleon I")))
.subject("You shall die! It's not me, it's Psychohistory")
.body("Hello Planet!")
.encoding("UTF-8").build();
emailService.send(email);
}
}
现在我只需要发送基本的纯文本电子邮件就可以了。但是,我确实需要能够在我发送的消息中指定自定义邮件类标头。我查看了源代码,但这个库似乎没有这种能力。我希望我错了。这可以做到吗?