7
7
import org .springframework .mail .SimpleMailMessage ;
8
8
import org .springframework .mail .javamail .JavaMailSender ;
9
9
import org .springframework .mail .javamail .MimeMessageHelper ;
10
+ import org .springframework .scheduling .annotation .Async ;
10
11
import org .springframework .stereotype .Service ;
11
12
import org .springframework .util .FileCopyUtils ;
12
13
@@ -41,6 +42,7 @@ public class MailSenderService {
41
42
/**
42
43
* 普通文本邮件
43
44
*/
45
+ @ Async
44
46
public void sendSimple (String receiverEmail , String content , String subject ) {
45
47
SimpleMailMessage message = new SimpleMailMessage ();
46
48
message .setFrom ("cpwu@foxmail.com" );
@@ -53,6 +55,7 @@ public void sendSimple(String receiverEmail, String content, String subject) {
53
55
/**
54
56
* HTML内容邮件
55
57
*/
58
+ @ Async
56
59
public void sendHTMLMessage (String receiverEmail , String htmlString ,
57
60
String subject , String senderEmail , String senderName ) throws MessagingException , UnsupportedEncodingException {
58
61
MimeMessage message = sender .createMimeMessage ();
@@ -69,6 +72,7 @@ public void sendHTMLMessage(String receiverEmail, String htmlString,
69
72
/**
70
73
* 使用JetBrick模板引擎渲染HTML邮件内容
71
74
*/
75
+ @ Async
72
76
public void sendTemplateMessage (String receiverEmail , Map <String , Object > param , String templatePath , String subject ,
73
77
String senderEmail , String senderName ) throws IOException , MessagingException {
74
78
String renderString = render (param , templatePath );
0 commit comments