Commit f040d3fc authored by xianghengxiang's avatar xianghengxiang
Browse files

发送邮件通知使用ssl方式,大多数服务器都禁用了25端口

parent 34dd88bd
......@@ -11,6 +11,8 @@ import org.springframework.context.annotation.Configuration;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.JavaMailSenderImpl;
import java.util.Properties;
@Configuration
@EnableConfigurationProperties(NotifyProperties.class)
public class NotifyAutoConfiguration {
......@@ -59,6 +61,17 @@ public class NotifyAutoConfiguration {
mailSender.setHost(mailConfig.getHost());
mailSender.setUsername(mailConfig.getUsername());
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;
}
......
......@@ -43,7 +43,7 @@ public class NotifyProperties {
private String password;
private String sendfrom;
private String sendto;
private Integer port;
public boolean isEnable() {
return enable;
}
......@@ -91,6 +91,14 @@ public class NotifyProperties {
public void setSendto(String sendto) {
this.sendto = sendto;
}
public Integer getPort() {
return port;
}
public void setPort(Integer port) {
this.port = port;
}
}
public static class Sms {
......
......@@ -20,7 +20,7 @@ litemall:
password: XXXXXXXXXXXXX
sendfrom: ex@ex.com.cn
sendto: ex@qq.com
port: 465
# 短消息模版通知配置
# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
sms:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment