2 Star 3 Fork 1

Ksnow / magic-api-plugin-mail

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

magic-api-plugin-mail

介绍

  • 用于magic-api 的邮件插件
  • 支持报错接口日志邮件通知,模板邮件发送

部署步骤

maven编译

 mvn clean install

pom引入

<!-- 邮件 -->
<dependency>
    <groupId>cn.luow</groupId>
    <artifactId>magic-api-plugin-mail</artifactId>
    <version>2.0.0</version>
</dependency>

配置spring-mail

spring:  
  mail:
    host: smtp.exmail.qq.com # 发件服务器
    username: xxx@xx.cn # 账号
    password: xxxx # 密码(163需要授权第三方登录密码,请查看设置-客户端授权码密码开通)
    port: 465
    protocol: smtp
    default-encoding: utf-8
    properties:
      mail:
        smtp:
          auth: true
          ssl:
            enable: true
            socketFactory:
              class: com.fintech.modules.base.util.mail.MailSSLSocketFactory

配置默认邮箱

magic-api:
  mail:
    to: xxxx@qq.com #默认发送邮箱
    duration: 5 #相同错误邮件最短发送间隔(分钟)
    defaultFtl: default #默认模板
    logFtl: error-mail #默认日志模板
    keyword: logMail #标记需要邮件监控的接口的关键字
#    webName: '[残叶小站]' #项目名
#    webUrl: 'https://localhost:9999' #项目地址

使用说明

发送邮件

import mail;
//发送普通邮件给默认邮箱
mail.sendSimpleMail("测试","这是一封测试邮件")
//发送普通邮件给xxxx
mail.sendSimpleMail("测试","这是一封测试邮件","xxxx@qq.com")
//使用默认模板发送邮件给默认邮箱
mail.send("测试","这是一封测试邮件")
//使用自定义ftl模板发送邮件给xxxx
mail.send("测试",xxxFtl,{content:xxx,...},"xxxx@qq.com")
  • 内置了一个默认模板,如需添加新的模板,请放到/templates下
  • 内置了一个日志模板,如需添加新的模板,请放到/templates下
  • 需要邮件报错提醒的接口,在对应接口的接口选项里添加标记

    logMail : true

MIT License Copyright (c) 2022 Ksnow 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.

简介

用于magic-api的邮件插件 支持报错接口日志邮件通知,模板邮件发送 展开 收起
Java 等 2 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/KS_snow/magic-api-plugin-mail.git
git@gitee.com:KS_snow/magic-api-plugin-mail.git
KS_snow
magic-api-plugin-mail
magic-api-plugin-mail
master

搜索帮助