如何在 Spring MVC 中发送 HTML 电子邮件? [英] How do I send HTML email in Spring MVC?

查看:30
本文介绍了如何在 Spring MVC 中发送 HTML 电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have successfully sent simple email using this:

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. 
" +
        "Thanks 
 Regards 
 Saurabh ");
mailSender.send(mailMessage);

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

What setting i need to chnage so that i can send html emails

推荐答案

我不认为 SimpleMailMessage 类有这样的选项.

I don't think that SimpleMailMessage class has such options.

我确信您可以使用 JavaMailSender 和 MimeMessagePreparator 来实现,因为您需要为 HTML 设置 MIME 内容类型.

I'm sure that you can do it with JavaMailSender and MimeMessagePreparator, because you need to set MIME content type for HTML.

查看此链接以获得帮助:

See this link for help:

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

这篇关于如何在 Spring MVC 中发送 HTML 电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆