## 去掉发送邮件相关内容;
This commit is contained in:
parent
7c274a3b0a
commit
c9e567fa6a
|
@ -1,44 +0,0 @@
|
|||
package com.hzs.third.sms.service;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: yuhui
|
||||
* @Time: 2023/3/30 17:01
|
||||
* @Classname: IMailService
|
||||
* @PackageName: com.hzs.third.sms.service
|
||||
*/
|
||||
public interface IMailService {
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mail 邮件账号
|
||||
* @param title 邮件标题
|
||||
* @param content 邮件内容
|
||||
* @return
|
||||
*/
|
||||
Boolean sendMail(String mail,String title,String content);
|
||||
|
||||
/**
|
||||
* 发送带附件的邮件信息
|
||||
* @param to 接收方
|
||||
* @param subject 邮件主题
|
||||
* @param content 邮件内容
|
||||
* @param files 多个附件集合
|
||||
* @return
|
||||
*/
|
||||
Boolean sendMessageCarryFiles(String to, String subject, String content, File[] files);
|
||||
|
||||
/**
|
||||
* 发送带附件的邮件信息
|
||||
*
|
||||
* @param to 接收方
|
||||
* @param subject 邮件主题
|
||||
* @param content 邮件内容(发送内容)
|
||||
* @param file 单个文件
|
||||
* @return
|
||||
*/
|
||||
Boolean sendMessageCarryFile(String to, String subject, String content, File file);
|
||||
}
|
|
@ -1,105 +0,0 @@
|
|||
package com.hzs.third.sms.service.impl;/**
|
||||
* @Description:
|
||||
* @Author: yuhui
|
||||
* @Time: 2023/3/30 17:02
|
||||
* @Classname: IMailServiceImpl
|
||||
* @PackageName: com.hzs.third.sms.service.impl
|
||||
*/
|
||||
|
||||
import com.hzs.third.sms.service.IMailService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.mail.SimpleMailMessage;
|
||||
import org.springframework.mail.javamail.JavaMailSender;
|
||||
import org.springframework.mail.javamail.MimeMessageHelper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*@BelongsProject: hzs_cloud
|
||||
*@BelongsPackage: com.hzs.third.sms.service.impl
|
||||
*@Author: yh
|
||||
*@CreateTime: 2023-03-30 17:02
|
||||
*@Description: TODO
|
||||
*@Version: 1.0
|
||||
*/
|
||||
@Service
|
||||
public class IMailServiceImpl implements IMailService {
|
||||
|
||||
@Value("${spring.mail.from}")
|
||||
private String from; // 发送发邮箱地址
|
||||
@Autowired
|
||||
private JavaMailSender mailSender;
|
||||
|
||||
@Override
|
||||
public Boolean sendMail(String mail,String title,String content) {
|
||||
try {
|
||||
// 创建一个邮件对象
|
||||
SimpleMailMessage msg = new SimpleMailMessage();
|
||||
msg.setFrom(from); // 设置发送发
|
||||
msg.setTo(mail); // 设置接收方
|
||||
msg.setSubject(title); // 设置邮件主题
|
||||
msg.setText(content); // 设置邮件内容
|
||||
// 发送邮件
|
||||
mailSender.send(msg);
|
||||
return true;
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sendMessageCarryFiles(String to, String subject, String content, File[] files) {
|
||||
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||
try {
|
||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true);
|
||||
helper.setFrom(from); // 设置发送发
|
||||
helper.setTo(to); // 设置接收方
|
||||
helper.setSubject(subject); // 设置邮件主题
|
||||
helper.setText(content); // 设置邮件内容
|
||||
if (files != null && files.length > 0) { // 添加附件(多个)
|
||||
for (File file : files) {
|
||||
helper.addAttachment(file.getName(), file);
|
||||
}
|
||||
}
|
||||
// 发送邮件
|
||||
mailSender.send(mimeMessage);
|
||||
return true;
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean sendMessageCarryFile(String to, String subject, String content, File file) {
|
||||
MimeMessage mimeMessage = mailSender.createMimeMessage();
|
||||
try {
|
||||
MimeMessageHelper helper = new MimeMessageHelper(mimeMessage,true);
|
||||
helper.setFrom(from); // 设置发送发
|
||||
helper.setTo(to); // 设置接收方
|
||||
helper.setSubject(subject); // 设置邮件主题
|
||||
helper.setText(content); // 设置邮件内容
|
||||
helper.addAttachment(file.getName(), file); // 单个附件
|
||||
// 发送邮件
|
||||
mailSender.send(mimeMessage);
|
||||
return true;
|
||||
} catch (MessagingException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public String getFrom() {
|
||||
return from;
|
||||
}
|
||||
|
||||
public void setFrom(String from) {
|
||||
this.from = from;
|
||||
}
|
||||
}
|
|
@ -287,11 +287,6 @@ express:
|
|||
key: sYeoOftD3060
|
||||
customer: 93A50C6B396F2728ABC75F2E62D8FE5F
|
||||
|
||||
## 邮件配置
|
||||
mall:
|
||||
## 邮件发送方
|
||||
from: welcome_xhzs@outlook.com
|
||||
|
||||
## 银行卡四要素验证
|
||||
bankCard:
|
||||
url: https://yhk4yshy.market.alicloudapi.com/yhksiys/dmp/api/jinrun.bank.verify.bank.info4
|
||||
|
|
Loading…
Reference in New Issue