|
@@ -11,6 +11,8 @@ import org.springframework.context.annotation.Configuration;
|
|
|
import org.springframework.mail.javamail.JavaMailSender;
|
|
import org.springframework.mail.javamail.JavaMailSender;
|
|
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
|
import org.springframework.mail.javamail.JavaMailSenderImpl;
|
|
|
|
|
|
|
|
|
|
+import java.util.Properties;
|
|
|
|
|
+
|
|
|
@Configuration
|
|
@Configuration
|
|
|
@EnableConfigurationProperties(NotifyProperties.class)
|
|
@EnableConfigurationProperties(NotifyProperties.class)
|
|
|
public class NotifyAutoConfiguration {
|
|
public class NotifyAutoConfiguration {
|
|
@@ -59,6 +61,17 @@ public class NotifyAutoConfiguration {
|
|
|
mailSender.setHost(mailConfig.getHost());
|
|
mailSender.setHost(mailConfig.getHost());
|
|
|
mailSender.setUsername(mailConfig.getUsername());
|
|
mailSender.setUsername(mailConfig.getUsername());
|
|
|
mailSender.setPassword(mailConfig.getPassword());
|
|
mailSender.setPassword(mailConfig.getPassword());
|
|
|
|
|
+ mailSender.setPort(mailConfig.getPort());
|
|
|
|
|
+ Properties properties = new Properties();
|
|
|
|
|
+ properties.put("mail.smtp.auth",true);
|
|
|
|
|
+ properties.put("mail.smtp.timeout",5000);
|
|
|
|
|
+ properties.put("mail.smtp.starttls.enable",true);
|
|
|
|
|
+ properties.put("mail.smtp.socketFactory.fallback", "false");
|
|
|
|
|
+ //阿里云 必须加入配置 outlook配置又不需要 视情况而定.发送不成功多数是这里的配置问题
|
|
|
|
|
+ properties.put("mail.smtp.socketFactory.class", "javax.net.ssl.SSLSocketFactory");
|
|
|
|
|
+ properties.put("mail.smtp.socketFactory.port", mailConfig.getPort());
|
|
|
|
|
+ properties.put("debug", true);
|
|
|
|
|
+ mailSender.setJavaMailProperties(properties);
|
|
|
return mailSender;
|
|
return mailSender;
|
|
|
}
|
|
}
|
|
|
|
|
|