|
@@ -1,14 +1,16 @@
|
|
|
package org.dromara.demo.controller;
|
|
package org.dromara.demo.controller;
|
|
|
|
|
|
|
|
|
|
+import cn.dev33.satoken.annotation.SaIgnore;
|
|
|
|
|
+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;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
|
+import java.util.Arrays;
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -16,6 +18,7 @@ import java.io.File;
|
|
|
*
|
|
*
|
|
|
* @author Michelle.Chung
|
|
* @author Michelle.Chung
|
|
|
*/
|
|
*/
|
|
|
|
|
+@SaIgnore
|
|
|
@Validated
|
|
@Validated
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
@RestController
|
|
@RestController
|
|
@@ -49,4 +52,19 @@ public class MailController {
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 发送邮件(多附件)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param to 接收人
|
|
|
|
|
+ * @param subject 标题
|
|
|
|
|
+ * @param text 内容
|
|
|
|
|
+ * @param paths 附件路径
|
|
|
|
|
+ */
|
|
|
|
|
+ @GetMapping("/sendMessageWithAttachments")
|
|
|
|
|
+ public R<Void> sendMessageWithAttachments(String to, String subject, String text, String[] paths) {
|
|
|
|
|
+ File[] array = Arrays.stream(paths).map(File::new).toArray(File[]::new);
|
|
|
|
|
+ MailUtils.sendText(to, subject, text, array);
|
|
|
|
|
+ return R.ok();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|