52 Star 173 Fork 47

编程界的小学生 / common-boot-email

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

common-boot-email

项目介绍

SpringBoot发送邮件神器,只需简单配置即可,支持自定义模板。

软件架构

SpringBoot+spring-boot-starter-mail +spring-boot-starter-thymeleaf

安装教程

  1. mvn install 打包到本地仓库,然后引入gav坐标。
  2. 后期会制作boot-starter。

使用说明

  1. text普通文本发送(MailContentTypeEnum.TEXT)

    @Autowired
    private MailBiz mailBiz;
    
    public void sendMail() {
    	mailBiz
            .contentType(MailContentTypeEnum.TEXT)
            .title("测试")
            .to("1104399635@qq.com")
            .content("测试content")
            .send();
    }
  2. html格式发送(MailContentTypeEnum.HTML)

    @Autowired
    private MailBiz mailBiz;
    
    public void sendMail() {
    	mailBiz
            .contentType(MailContentTypeEnum.HTML)
            .title("测试")
            .to("1104399635@qq.com")
            .content("<h1>测试content</h1>")
            .send();
    }
  3. 自定义模板发送(MailContentTypeEnum.TEMPLATE)

    @Autowired
    private MailBiz mailBiz;
    
    public void sendMail() {
    	Map<String, Object> params = new HashMap<>();
    	params.put("href", "http://www.baidu.com");
    	mailBiz
            .contentType(MailContentTypeEnum.TEMPLATE)
            .title("测试")
            .to("1104399635@qq.com")
            .content("测试content")
            .templateName("regist-template")
            .maps(params)
            .send();
    }
    
    /**
     * @Description: 模板名称枚举
     *
     * @author TongWei.Chen 2018-6-19 10:54:35
     * @Project tucaole
     */
    public enum EmailTemplateEnum {
        /**
         * 注册模板
         */
        REGIST_TEMPLATE("regist-template")
        ;
    
        EmailTemplateEnum(String value) {
            this.value = value;
        }
    
        private String value;
    
        public String value() {
            return value;
        }
    }
    我有个xxx-common-email模块,将所有email模板都放到了resources/templates/里。
The MIT License (MIT) Copyright (c) 2018 编程界的小学生 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

SpringBoot发送邮件神器,只需简单配置即可,支持自定义模板。 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/geekerdream/common-boot-email.git
git@gitee.com:geekerdream/common-boot-email.git
geekerdream
common-boot-email
common-boot-email
master

搜索帮助