我已经成功地使用这个发送了简单的电子邮件:
SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setTo("someone@abc.example");
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 电子邮件
原文由 John 发布,翻译遵循 CC BY-SA 4.0 许可协议
我认为 SimpleMailMessage 类没有这样的选项。
我确信您可以使用 JavaMailSender 和 MimeMessagePreparator 来完成它,因为您需要为 HTML 设置 MIME 内容类型。
请参阅此链接以获取帮助:
http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/mail.html