燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2024-11-20 8185e5cdc2bbdf7fb4ca46a10864106893a01ed3
src/main/java/com/yssh/service/EmailService.java
@@ -1,5 +1,6 @@
package com.yssh.service;
import com.yssh.config.InitConfig;
import com.yssh.mapper.QxshMapper;
import com.yssh.utils.StringUtils;
import org.slf4j.Logger;
@@ -15,12 +16,6 @@
import java.text.SimpleDateFormat;
import java.util.*;
/**
 * 邮件服务类
 *
 * @author www
 * @date 2024-03-21
 */
@Service
public class EmailService {
    @Value("${email.userName}")
@@ -86,14 +81,13 @@
    protected final Logger logger = LoggerFactory.getLogger(this.getClass());
    public Session createSession() {
        // 创建一个配置文件,并保存
        Properties props = new Properties();
        // SMTP服务器连接信息:126—smtp.126.com,163—smtp.163.com,qq-smtp.qq.com"
        props.put("mail.smtp.host", smtpHost); // SMTP主机名
        props.put("mail.smtp.port", smtpPort); // 主机端口号:126—25,163—645,qq-587
        props.put("mail.smtp.auth", smtpAuth); // 是否需要用户认证
        props.put("mail.smtp.starttls.enale", smtpTls); // 启用TlS加密
        // 126—smtp.126.com,163—smtp.163.com,qq-smtp.qq.com"
        props.put("mail.smtp.host", smtpHost);
        props.put("mail.smtp.port", smtpPort);
        props.put("mail.smtp.auth", smtpAuth);
        props.put("mail.smtp.starttls.enale", smtpTls);
        Session session = Session.getInstance(props, new Authenticator() {
            @Override
@@ -102,7 +96,6 @@
            }
        });
        // 控制台打印调试信息
        session.setDebug(debug);
        return session;
@@ -114,10 +107,8 @@
                return null;
            }
            // 创建Session会话
            Session session = createSession();
            // 创建邮件对象
            MimeMessage message = new MimeMessage(session);
            message.setSubject(title);
            message.setText(text);
@@ -133,7 +124,6 @@
                message.setRecipients(Message.RecipientType.CC, ias);
            }
            // 发送
            Transport.send(message);
            return true;
@@ -237,7 +227,7 @@
    public Calendar getCalendar(int start) {
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(new Date());
        calendar.setTime(InitConfig.getDate());
        calendar.add(Calendar.HOUR, start);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);