首页 > 编程语言 > 详细

springboot 整合mail功能

时间:2019-10-23 14:03:47      阅读:105      评论:0      收藏:0      [点我收藏+]
今天完善
目标 

 

 1     public String content() {
 2         try {
 3             Configuration configuration = new Configuration(Configuration.getVersion());
 4 
 5 //      ’加载模板文件
 6             // ‘模板内容,这里测试时使用简单的字符串作为模板
 7             String templateString = "" + "<html>\n" + " <head></head>\n" + " <body>\n"
 8                     + " <font color=‘red‘ size=‘30‘>名称:${name}</font>\n" + " </body>\n" + "</html>";
 9 
10             // ’创建模板加载器
11             StringTemplateLoader templateLoader = new StringTemplateLoader();
12 
13 //     ‘ 存入模板
14             templateLoader.putTemplate("template", templateString); // template = 虚拟名称, 用来当作获取静态文件的key
15 
16             // ’加载模板加载器
17             configuration.setTemplateLoader(templateLoader);
18 
19             // ‘ 得到模板
20             Template template = configuration.getTemplate("template", "utf-8");
21 
22             // ’创建模型数据
23             Map<String, Object> map = new HashMap<String, Object>();
24 
25             map.put("name", "张三");
26 
27             // ‘执行静态化 方式1 获取静态化内容
28             String content = FreeMarkerTemplateUtils.processTemplateIntoString(template, map);
29             System.out.println(content);// 静态化内容
30             return content;
31         } catch (Exception e) {
32             return null;
33         }
34 
35     }

 

springboot 整合mail功能

原文:https://www.cnblogs.com/xiaoshahai/p/11725811.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!