From ac40a4fe665f519a2a75bd83e668e75ef8f8cb3e Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期二, 18 三月 2025 10:31:03 +0800
Subject: [PATCH] Merge branch 'xizang-changyun' of https://gitee.com/xiaochen991015/xizang

---
 ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java |   31 +++++++++----------------------
 1 files changed, 9 insertions(+), 22 deletions(-)

diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java
index 4ce4421..a6e40ba 100644
--- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java
@@ -121,27 +121,20 @@
         try {
             // 创建邮件会话
             Session mailSession = Session.getInstance(getMailProperties(), getAuthenticator());
-
             // 创建邮件消息
             MimeMessage message = new MimeMessage(mailSession);
-
             // 设置发件人
             InternetAddress from = new InternetAddress(properties.getUserAddr(), properties.getUserName());
             message.setFrom(from);
-
             // 设置收件人
             InternetAddress to = new InternetAddress(emailAddress);
             message.setRecipient(MimeMessage.RecipientType.TO, to);
-
             // 设置邮件标题
             message.setSubject("发票");
-
             // 创建邮件内容
             Multipart multipart = createMultipart(list);
-
             // 设置邮件内容
             message.setContent(multipart);
-
             // 发送邮件
             Transport.send(message);
         } catch (MessagingException | UnsupportedEncodingException | MalformedURLException e) {
@@ -160,7 +153,8 @@
         props.put("mail.user", properties.getUserAddr());
         props.put("mail.password", properties.getPassword());
         props.setProperty("mail.smtp.socketFactory.fallback", "false");
-        props.put("mail.smtp.ssl.enable", "false");
+        props.put("mail.smtp.ssl.enable", "true");
+        props.put("mail.smtp.ssl.protocols", "TLSv1.2");
         return props;
     }
 
@@ -175,42 +169,35 @@
         };
     }
 
-
-
-
     private Multipart createMultipart(List<Map<String, String>> list) throws MessagingException, UnsupportedEncodingException, MalformedURLException {
         Multipart multipart = new MimeMultipart();
-
         // 添加文本消息部分
         BodyPart messageBodyPart = new MimeBodyPart();
         messageBodyPart.setHeader("Content-Type", "text/plain;charset=utf-8");
+        messageBodyPart.setContent("您在小程序提交的开票申请已开票成功,请查看附件内容","text/html;charset=UTF-8");
         multipart.addBodyPart(messageBodyPart);
-
         // 添加附件部分
         for (Map<String, String> map : list) {
             messageBodyPart = new MimeBodyPart();
             String url = map.get("url");
             String fileName = map.get("fileName");
-
             URLDataSource source = new URLDataSource(new URL(url));
             messageBodyPart.setDataHandler(new DataHandler(source));
-
             String filenameEncode = MimeUtility.encodeText(fileName, "UTF-8", "base64");
             messageBodyPart.setFileName(filenameEncode);
             messageBodyPart.setHeader("Content-Transfer-Encoding", "base64");
             messageBodyPart.setHeader("Content-Disposition", "attachment");
             messageBodyPart.setHeader("Content-Type", "application/octet-stream;name=\"" + filenameEncode + "\"");
-
             multipart.addBodyPart(messageBodyPart);
         }
 
         return multipart;
     }
 
-   public static void main(String[] args) throws UnsupportedEncodingException {
-       TencentMailUtil tencentMailUtil = new TencentMailUtil();
-       MailProperties properties = new MailProperties();
-       tencentMailUtil.properties = properties;
-       tencentMailUtil.send("645025773@qq.com","大学城揽院24栋");
-   }
+   // public static void main(String[] args) throws UnsupportedEncodingException {
+   //     TencentMailUtil tencentMailUtil = new TencentMailUtil();
+   //     MailProperties properties = new MailProperties();
+   //     tencentMailUtil.properties = properties;
+   //     tencentMailUtil.send("645025773@qq.com","大学城揽院24栋");
+   // }
 }

--
Gitblit v1.7.1