|
@@ -0,0 +1,49 @@
|
|
|
|
+package com.xxl.job.admin.core.conf;
|
|
|
|
+
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
|
+import org.springframework.mail.javamail.JavaMailSenderImpl;
|
|
|
|
+
|
|
|
|
+import java.util.Properties;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * @Description: MailConfiguration
|
|
|
|
+ * @Author: xda
|
|
|
|
+ * @Date: 2021/7/23 14:13
|
|
|
|
+ */
|
|
|
|
+@Configuration
|
|
|
|
+public class MailConfiguration {
|
|
|
|
+
|
|
|
|
+ @Value("${spring.mail.host}")
|
|
|
|
+ private String host;
|
|
|
|
+
|
|
|
|
+ @Value("${spring.mail.port}")
|
|
|
|
+ private int port;
|
|
|
|
+
|
|
|
|
+ @Value("${spring.mail.username}")
|
|
|
|
+ private String username;
|
|
|
|
+
|
|
|
|
+ @Value("${spring.mail.password}")
|
|
|
|
+ private String password;
|
|
|
|
+
|
|
|
|
+ @Bean
|
|
|
|
+ public JavaMailSenderImpl javaMailSender() {
|
|
|
|
+ Properties properties = new Properties();
|
|
|
|
+ properties.setProperty("mail.smtp.auth", "true");
|
|
|
|
+ properties.setProperty("mail.smtp.starttls.enable", "true");
|
|
|
|
+ properties.setProperty("mail.smtp.starttls.required", "true");
|
|
|
|
+ properties.setProperty("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
|
|
|
+
|
|
|
|
+ JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
|
|
|
|
+ mailSender.setHost(host);
|
|
|
|
+ mailSender.setUsername(username);
|
|
|
|
+ mailSender.setPassword(password);
|
|
|
|
+ mailSender.setPort(port);
|
|
|
|
+ mailSender.setJavaMailProperties(properties);
|
|
|
|
+ return mailSender;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+}
|