Commit cedbdd12 authored by fangxinjiang's avatar fangxinjiang

邮件服务

parent fb44737d
package com.yifu.cloud.plus.v1.mail.entity;
import lombok.Data;
/**
* @Author fxj
* @Date 2022/12/8
* @Description
* @Version 1.0
*/
@Data
public class Email {
private String[] user;
private String subject;
private String content;
}
package com.yifu.cloud.plus.v1.mail.service; package com.yifu.cloud.plus.v1.mail.service;
import com.sun.xml.internal.ws.resources.SenderMessages;
import com.yifu.cloud.plus.v1.mail.entity.Email;
/** /**
* @Author fxj * @Author fxj
...@@ -11,6 +12,6 @@ import com.sun.xml.internal.ws.resources.SenderMessages; ...@@ -11,6 +12,6 @@ import com.sun.xml.internal.ws.resources.SenderMessages;
**/ **/
public interface MailService { public interface MailService {
Boolean sendMail(SenderMessages messages); Boolean sendMail(Email email);
} }
package com.yifu.cloud.plus.v1.mail.service.impl; package com.yifu.cloud.plus.v1.mail.service.impl;
import com.sun.xml.internal.ws.resources.SenderMessages; import com.yifu.cloud.plus.v1.mail.entity.Email;
import com.yifu.cloud.plus.v1.mail.service.MailService; import com.yifu.cloud.plus.v1.mail.service.MailService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage; import org.springframework.mail.SimpleMailMessage;
...@@ -18,9 +18,9 @@ public class MailServiceImpl implements MailService { ...@@ -18,9 +18,9 @@ public class MailServiceImpl implements MailService {
private JavaMailSender mailSender; private JavaMailSender mailSender;
@Override @Override
public Boolean sendMail(SenderMessages messages) { public Boolean sendMail(Email email) {
SimpleMailMessage mailMessage = new SimpleMailMessage(); SimpleMailMessage mailMessage = new SimpleMailMessage();
mailMessage.setFrom("fangxinjiang@wanxin-holdings.com"); mailMessage.setFrom("information@wanxin-holdings.com");
mailMessage.setTo("fangxinjiang@wanxin-holdings.com"); mailMessage.setTo("fangxinjiang@wanxin-holdings.com");
mailMessage.setText("你好 hello world"); mailMessage.setText("你好 hello world");
mailMessage.setSubject("测试Spring邮箱服务"); mailMessage.setSubject("测试Spring邮箱服务");
......
...@@ -10,12 +10,19 @@ spring: ...@@ -10,12 +10,19 @@ spring:
host: 127.0.0.1 host: 127.0.0.1
password: '@yf_2017' password: '@yf_2017'
mail: mail:
host: smtp.wanxin-holdings.com host: smtp.exmail.qq.com
port: 465 port: 465
username: information@wanxin-holdings.com username: information@wanxin-holdings.com
password: QmdCaQSPmCAQEddd password: QmdCaQSPmCAQEddd
protocol: smtp protocol: smtp
default-encoding: UTF-8 default-encoding: UTF-8
properties:
mail.smtp.auth: true
mail.smtp.starttls.enable: true
mail.smtp.starttls.required: true
mail.smtp.socketFactory.port: 465
mail.smtp.socketFactory.class: javax.net.ssl.SSLSocketFactory
mail.smtp.socketFactory.fallback: false
datasource: datasource:
type: com.zaxxer.hikari.HikariDataSource type: com.zaxxer.hikari.HikariDataSource
driver-class-name: com.mysql.cj.jdbc.Driver driver-class-name: com.mysql.cj.jdbc.Driver
...@@ -44,4 +51,5 @@ security: ...@@ -44,4 +51,5 @@ security:
urls: urls:
- /v3/api-docs - /v3/api-docs
- /actuator/** - /actuator/**
- /swagger-ui/** - /swagger-ui/**
\ No newline at end of file - /sendMail/**
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment