1 Commits

Author SHA1 Message Date
HJ Wu
89244560e9 Merge be32fd8914 into 64100cf1ff 2025-07-02 01:53:16 +00:00

View File

@@ -1,5 +1,6 @@
package org.dromara.demo.controller; package org.dromara.demo.controller;
import cn.dev33.satoken.annotation.SaIgnore;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.mail.utils.MailUtils; import org.dromara.common.mail.utils.MailUtils;
@@ -17,6 +18,7 @@ import java.util.Arrays;
* *
* @author Michelle.Chung * @author Michelle.Chung
*/ */
@SaIgnore
@Validated @Validated
@RequiredArgsConstructor @RequiredArgsConstructor
@RestController @RestController
@@ -42,11 +44,11 @@ public class MailController {
* @param to 接收人 * @param to 接收人
* @param subject 标题 * @param subject 标题
* @param text 内容 * @param text 内容
* @param filePath 附件路径
*/ */
@GetMapping("/sendMessageWithAttachment") @GetMapping("/sendMessageWithAttachment")
public R<Void> sendMessageWithAttachment(String to, String subject, String text) { public R<Void> sendMessageWithAttachment(String to, String subject, String text, String filePath) {
// 附件路径 禁止前端传递 有任意读取系统文件风险 MailUtils.sendText(to, subject, text, new File(filePath));
MailUtils.sendText(to, subject, text, new File("/xxx/xxx"));
return R.ok(); return R.ok();
} }
@@ -56,11 +58,10 @@ public class MailController {
* @param to 接收人 * @param to 接收人
* @param subject 标题 * @param subject 标题
* @param text 内容 * @param text 内容
* @param paths 附件路径
*/ */
@GetMapping("/sendMessageWithAttachments") @GetMapping("/sendMessageWithAttachments")
public R<Void> sendMessageWithAttachments(String to, String subject, String text) { public R<Void> sendMessageWithAttachments(String to, String subject, String text, String[] paths) {
// 附件路径 禁止前端传递 有任意读取系统文件风险
String[] paths = new String[]{"/xxx/xxx", "/xxx/xxx"};
File[] array = Arrays.stream(paths).map(File::new).toArray(File[]::new); File[] array = Arrays.stream(paths).map(File::new).toArray(File[]::new);
MailUtils.sendText(to, subject, text, array); MailUtils.sendText(to, subject, text, array);
return R.ok(); return R.ok();