From 8185e5cdc2bbdf7fb4ca46a10864106893a01ed3 Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期三, 20 十一月 2024 15:30:12 +0800 Subject: [PATCH] 1 --- src/main/java/com/yssh/service/EmailService.java | 29 +++++++++++------------------ 1 files changed, 11 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/yssh/service/EmailService.java b/src/main/java/com/yssh/service/EmailService.java index f1fa2c5..192131d 100644 --- a/src/main/java/com/yssh/service/EmailService.java +++ b/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}") @@ -71,6 +66,9 @@ @Value("${email.enable}") private Boolean enable; + @Value("${email.debug}") + private Boolean debug; + @Resource private QxshMapper qxshMapper; @@ -83,14 +81,13 @@ protected final Logger logger = LoggerFactory.getLogger(this.getClass()); public Session createSession() { - // 鍒涘缓涓�涓厤缃枃浠讹紝骞朵繚瀛� Properties props = new Properties(); - // SMTP鏈嶅姟鍣ㄨ繛鎺ヤ俊鎭細126鈥攕mtp.126.com锛�163鈥攕mtp.163.com锛宷q-smtp.qq.com" - props.put("mail.smtp.host", smtpHost); // SMTP涓绘満鍚� - props.put("mail.smtp.port", smtpPort); // 涓绘満绔彛鍙凤細126鈥�25锛�163鈥�645锛宷q-587 - props.put("mail.smtp.auth", smtpAuth); // 鏄惁闇�瑕佺敤鎴疯璇� - props.put("mail.smtp.starttls.enale", smtpTls); // 鍚敤TlS鍔犲瘑 + // 126鈥攕mtp.126.com锛�163鈥攕mtp.163.com锛宷q-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 @@ -99,8 +96,7 @@ } }); - // 鎺у埗鍙版墦鍗拌皟璇曚俊鎭� - session.setDebug(true); + session.setDebug(debug); return session; } @@ -111,10 +107,8 @@ return null; } - // 鍒涘缓Session浼氳瘽 Session session = createSession(); - // 鍒涘缓閭欢瀵硅薄 MimeMessage message = new MimeMessage(session); message.setSubject(title); message.setText(text); @@ -130,7 +124,6 @@ message.setRecipients(Message.RecipientType.CC, ias); } - // 鍙戦�� Transport.send(message); return true; @@ -234,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); -- Gitblit v1.9.3