hejinbo 2 年 前
コミット
c60ad9f3fc
共有3 個のファイルを変更した45 個の追加5 個の削除を含む
  1. 25
    0
      ruoyi-admin/src/main/resources/application.yml
  2. 7
    0
      ruoyi-common/pom.xml
  3. 13
    5
      ruoyi-common/src/main/java/com/ruoyi/common/utils/SendMailUtils.java

+ 25
- 0
ruoyi-admin/src/main/resources/application.yml ファイルの表示

@@ -91,6 +91,31 @@ spring:
91 91
   web:
92 92
     resources:
93 93
       static-locations:  file:/home/ruoyi/
94
+  mail:
95
+    # 邮件服务地址
96
+    host: smtp.163.com
97
+    # 默认端口25,可不写
98
+    port: 25
99
+    # 编码格式
100
+    default-encoding: utf-8
101
+    # 发送者用户名
102
+    username: xxx@163.com
103
+    # 授权码,刚才获取的代码
104
+    password: xxx
105
+    # 其它参数
106
+    #    properties:
107
+    #      mail:
108
+    #        smtp:
109
+    #          # 如果是用 SSL 方式,需要配置如下属性
110
+    #          ssl:
111
+    #            enable: true
112
+    #            required: true
113
+    #          # 邮件接收时间的限制,单位毫秒
114
+    #          timeout: 10000
115
+    #          # 连接时间的限制,单位毫秒
116
+    #          connectiontimeout: 10000
117
+    #          # 邮件发送时间的限制,单位毫秒
118
+    #          writetimeout: 10000
94 119
 
95 120
 # token配置
96 121
 token:

+ 7
- 0
ruoyi-common/pom.xml ファイルの表示

@@ -152,6 +152,13 @@
152 152
             <version>1.9.1</version>
153 153
         </dependency>
154 154
 
155
+        <!--  发送邮件-->
156
+        <dependency>
157
+            <groupId>org.springframework.boot</groupId>
158
+            <artifactId>spring-boot-starter-mail</artifactId>
159
+            <version>3.1.4</version>
160
+        </dependency>
161
+
155 162
     </dependencies>
156 163
 
157 164
 </project>

+ 13
- 5
ruoyi-common/src/main/java/com/ruoyi/common/utils/SendMailUtils.java ファイルの表示

@@ -1,13 +1,21 @@
1
-package com.ruoyi.common.utils;
2
-
3
-import com.sun.xml.internal.messaging.saaj.packaging.mime.MessagingException;
4
-import org.springframework.core.io.FileSystemResource;
5
-import org.springframework.mail.javamail.MimeMessageHelper;
1
+//package com.ruoyi.common.utils;
2
+//
3
+//
4
+//import jakarta.mail.internet.MimeMessage;
5
+//import org.springframework.beans.factory.annotation.Autowired;
6
+//import org.springframework.core.io.FileSystemResource;
7
+//import org.springframework.mail.javamail.JavaMailSender;
8
+//import org.springframework.mail.javamail.MimeMessageHelper;
9
+//import org.springframework.stereotype.Component;
6 10
 //
7 11
 //import java.io.File;
8 12
 //import java.util.List;
9 13
 //
14
+//@Component
10 15
 //public class SendMailUtils {
16
+//    private static final String SENDER = "xxx@163.com";
17
+//    @Autowired
18
+//    private JavaMailSender mailSender;
11 19
 //    /**
12 20
 //     * 发送带附件的邮件
13 21
 //     *