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

查看:153
本文介绍了如何在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. \n" +
        "Thanks \n Regards \n 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天全站免登陆