Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
Litemall
Commits
207bf1e7
Unverified
Commit
207bf1e7
authored
Dec 16, 2019
by
linlinjava
Committed by
GitHub
Dec 16, 2019
Browse files
Merge pull request #307 from jessonxiang/master
发送邮件通知使用ssl方式,大多数服务器都禁用了25端口
parents
1d1c017b
f040d3fc
Changes
3
Hide whitespace changes
Inline
Side-by-side
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyAutoConfiguration.java
View file @
207bf1e7
...
@@ -11,6 +11,8 @@ import org.springframework.context.annotation.Configuration;
...
@@ -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 {
...
@@ -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
;
}
}
...
...
litemall-core/src/main/java/org/linlinjava/litemall/core/notify/config/NotifyProperties.java
View file @
207bf1e7
...
@@ -43,7 +43,7 @@ public class NotifyProperties {
...
@@ -43,7 +43,7 @@ public class NotifyProperties {
private
String
password
;
private
String
password
;
private
String
sendfrom
;
private
String
sendfrom
;
private
String
sendto
;
private
String
sendto
;
private
Integer
port
;
public
boolean
isEnable
()
{
public
boolean
isEnable
()
{
return
enable
;
return
enable
;
}
}
...
@@ -91,6 +91,14 @@ public class NotifyProperties {
...
@@ -91,6 +91,14 @@ public class NotifyProperties {
public
void
setSendto
(
String
sendto
)
{
public
void
setSendto
(
String
sendto
)
{
this
.
sendto
=
sendto
;
this
.
sendto
=
sendto
;
}
}
public
Integer
getPort
()
{
return
port
;
}
public
void
setPort
(
Integer
port
)
{
this
.
port
=
port
;
}
}
}
public
static
class
Sms
{
public
static
class
Sms
{
...
...
litemall-core/src/main/resources/application-core.yml
View file @
207bf1e7
...
@@ -20,7 +20,7 @@ litemall:
...
@@ -20,7 +20,7 @@ litemall:
password
:
XXXXXXXXXXXXX
password
:
XXXXXXXXXXXXX
sendfrom
:
ex@ex.com.cn
sendfrom
:
ex@ex.com.cn
sendto
:
ex@qq.com
sendto
:
ex@qq.com
port
:
465
# 短消息模版通知配置
# 短消息模版通知配置
# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
# 短信息用于通知客户,例如发货短信通知,注意配置格式;template-name,template-templateId 请参考 NotifyType 枚举值
sms
:
sms
:
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment