上一篇文章写了怎么在springboot2.x中添加服务监控,如果有需要的小伙伴可以回头看一眼,《springboot2.x中的服务监控》,可是这还需要我时不时的来登录一下系统查看一下,好麻烦,要是能有提醒就好了。当然我们想到的人家spring的大神早已想到,本来就来解决这个“不方便”
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-mail</artifactId> </dependency>
spring: application: name: spring-boot-admin-server mail: host: smtp.qq.com username: xxx@qq.com(你自己的邮箱账号) password: (对应的授权码,下面说明怎么获取该授权码) properties: mail.debug: false mail.smtp.auth: true #安全认证(默认是true) mail.smtp.port: 465 mail.smtp.ssl.enable: true #开启ssl加密 否则项目启动时报530error mail.smtp.ssl.socketFactory: sf mail.smtp.starttls.enable: true mail.smtp.starttls.required: true boot: admin: notify: mail: to:接收提醒的邮箱 from:发送人邮箱
这样就够了,重新测试你的服务,启动或者服务挂掉的时候邮箱都能收到提醒了。
以下以QQ邮箱为例(163等邮箱都大差不差) 登录后进入“邮箱设置”-->“帐户”--》往下拉--》开启POP3/SMTP
戳下面 https://gitee.com/QuanZhanZhiLu/easy-boot 获取源码