小编典典

如何在Spring MVC中发送HTML电子邮件?

spring-mvc

我已经使用此成功发送了简单的电子邮件:

SimpleMailMessage mailMessage = new SimpleMailMessage();

mailMessage.setTo("someone@abc.com");
mailMessage.setSubject("This is the test message for testing gmail smtp server using spring mail");
mailMessage.setFrom("abc@gmail.com");
mailMessage.setText("This is the test message for testing gmail smtp server using spring mail. \n" +
        "Thanks \n Regards \n Saurabh ");
mailSender.send(mailMessage);

我需要更改什么设置才能发送HTML电子邮件


阅读 400

收藏
2020-06-01

共1个答案

小编典典

我认为SimpleMailMessage类没有这样的选项。

我确定您可以使用JavaMailSender和MimeMessagePreparator做到这一点,因为您需要为HTML设置MIME内容类型。

请参阅此链接以获取帮助:

http://static.springsource.org/spring/docs/3.0.x/spring-framework-
reference/html/mail.html

2020-06-01