Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
T
TDLCloud
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WitCloud
TDLCloud
Commits
c3ec2aec
Commit
c3ec2aec
authored
Jan 16, 2023
by
Carit Zhu
🎱
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改eMail配置属性,添加mail.smtp.ssl.enable=true.
parent
ddb0bef2
Pipeline
#1873
passed with stage
in 0 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
10 deletions
+8
-10
MailUtil.java
src/main/java/com/example/tdl/util/MailUtil.java
+8
-10
No files found.
src/main/java/com/example/tdl/util/MailUtil.java
View file @
c3ec2aec
...
@@ -27,15 +27,13 @@ public class MailUtil {
...
@@ -27,15 +27,13 @@ public class MailUtil {
//设置发送邮件需要的属性
//设置发送邮件需要的属性
Properties
props
=
new
Properties
();
Properties
props
=
new
Properties
();
//主机地址
props
.
setProperty
(
"mail.smtp.host"
,
"smtp.qiye.163.com"
);
//设置主机地址
props
.
put
(
"mail.smtp.host"
,
"smtp.qiye.163.com"
);
props
.
setProperty
(
"mail.smtp.port"
,
"465"
);
//设置主机端口
//是否打开验证:必须打开
props
.
setProperty
(
"mail.smtp.auth"
,
"true"
);
//是否打开验证:必须打开
props
.
put
(
"mail.smtp.auth"
,
"true"
);
props
.
setProperty
(
"mail.smtp.socketFactory.class"
,
"javax.net.ssl.SSLSocketFactory"
);
props
.
setProperty
(
"mail.smtp.ssl.enable"
,
"true"
);
// 设置是否使用ssl安全连接 ---一般都使用
props
.
put
(
"mail.smtp.socketFactory.class"
,
"javax.net.ssl.SSLSocketFactory"
);
props
.
setProperty
(
"mail.smtp.socketFactory.fallback"
,
"false"
);
props
.
setProperty
(
"mail.smtp.socketFactory.fallback"
,
"false"
);
props
.
setProperty
(
"mail.smtp.socketFactory.port"
,
"465"
);
props
.
setProperty
(
"mail.smtp.port"
,
"465"
);
props
.
setProperty
(
"mail.smtp.socketFactory.port"
,
"465"
);
//取的与邮件服务器连接
//取的与邮件服务器连接
Session
session
=
Session
.
getDefaultInstance
(
props
);
Session
session
=
Session
.
getDefaultInstance
(
props
);
...
@@ -101,7 +99,7 @@ public class MailUtil {
...
@@ -101,7 +99,7 @@ public class MailUtil {
MimeMessage
msg
=
new
MimeMessage
(
session
);
MimeMessage
msg
=
new
MimeMessage
(
session
);
//2.设置发件人地址
//2.设置发件人地址
msg
.
setFrom
(
new
InternetAddress
(
senderAddress
));
msg
.
setFrom
(
new
InternetAddress
(
senderAddress
));
/*
*
/*
* 3.设置收件人地址(可以增加多个收件人、抄送、密送),即下面这一行代码书写多行
* 3.设置收件人地址(可以增加多个收件人、抄送、密送),即下面这一行代码书写多行
* MimeMessage.RecipientType.TO:发送
* MimeMessage.RecipientType.TO:发送
* MimeMessage.RecipientType.CC:抄送
* MimeMessage.RecipientType.CC:抄送
...
...
Write
Preview
Markdown
is supported
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