Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
sendmail
Overview
Overview
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
zhiwei
sendmail
Commits
51ea2333
Commit
51ea2333
authored
Apr 23, 2020
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加100M以下文件发送
parent
4b464581
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
7 deletions
+8
-7
pom.xml
+1
-1
src/main/java/com/zhiwei/sendmail/SimpleMailSender.java
+3
-2
src/test/java/com/zhiwei/sendmail/test/SendMailTest.java
+4
-4
No files found.
pom.xml
View file @
51ea2333
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.zhiwei
</groupId>
<groupId>
com.zhiwei
</groupId>
<artifactId>
sendmail
</artifactId>
<artifactId>
sendmail
</artifactId>
<version>
0.0.
3-SNAPSHOT
</version>
<version>
0.0.
4-SNAPSHOT
</version>
<name>
sendmail
</name>
<name>
sendmail
</name>
<description>
发送邮件
</description>
<description>
发送邮件
</description>
...
...
src/main/java/com/zhiwei/sendmail/SimpleMailSender.java
View file @
51ea2333
...
@@ -93,11 +93,11 @@ public class SimpleMailSender {
...
@@ -93,11 +93,11 @@ public class SimpleMailSender {
mailMessage
.
setSubject
(
mailInfo
.
getSubject
());
mailMessage
.
setSubject
(
mailInfo
.
getSubject
());
// 设置邮件消息发送的时间
// 设置邮件消息发送的时间
mailMessage
.
setSentDate
(
new
Date
());
mailMessage
.
setSentDate
(
new
Date
());
// MiniMultipart类是一个容器类,包含MimeBodyPart类型的对象
// MiniMultipart类是一个容器类,包含MimeBodyPart类型的对象
Multipart
multiPart
=
new
MimeMultipart
();
Multipart
multiPart
=
new
MimeMultipart
();
// 创建一个包含HTML内容的MimeBodyPart
// 创建一个包含HTML内容的MimeBodyPart
BodyPart
bodyPart
=
new
MimeBodyPart
();
BodyPart
bodyPart
=
new
MimeBodyPart
();
// 设置HTML内容
// 设置HTML内容
bodyPart
.
setContent
(
mailInfo
.
getContent
(),
"text/html; charset=utf-8"
);
bodyPart
.
setContent
(
mailInfo
.
getContent
(),
"text/html; charset=utf-8"
);
multiPart
.
addBodyPart
(
bodyPart
);
multiPart
.
addBodyPart
(
bodyPart
);
...
@@ -113,7 +113,8 @@ public class SimpleMailSender {
...
@@ -113,7 +113,8 @@ public class SimpleMailSender {
}
}
}
}
// 发送邮件
// 发送邮件
Transport
.
send
(
mailMessage
);
mailMessage
.
saveChanges
();
Transport
.
send
(
mailMessage
,
mailMessage
.
getAllRecipients
());
return
true
;
return
true
;
}
}
...
...
src/test/java/com/zhiwei/sendmail/test/SendMailTest.java
View file @
51ea2333
...
@@ -9,19 +9,19 @@ import com.zhiwei.sendmail.bean.MailInfo;
...
@@ -9,19 +9,19 @@ import com.zhiwei.sendmail.bean.MailInfo;
public
class
SendMailTest
{
public
class
SendMailTest
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// 这个类主要是设置邮件
// 这个类主要是设置邮件
String
mailServerHost
=
"smtp
.ym.163.com"
;
String
mailServerHost
=
"smtp
hz.qiye.163.com"
;
String
mailServerPort
=
"25"
;
String
mailServerPort
=
"25"
;
String
fromAddress
=
"zhangzhiwei@zhiweidata.com"
;
String
fromAddress
=
"zhangzhiwei@zhiweidata.com"
;
String
fromName
=
"测试"
;
String
fromName
=
"测试"
;
String
toAddress
=
"
859548429@qq.com"
;
String
toAddress
=
"
yuchengyi@zhiweidata.com"
;
String
userName
=
"zhangzhiwei@zhiweidata.com"
;
String
userName
=
"zhangzhiwei@zhiweidata.com"
;
String
password
=
"olp1437z.."
;
String
password
=
"olp1437z.."
;
boolean
validate
=
true
;
boolean
validate
=
true
;
String
subject
=
"带附件的邮件测试程序"
;
String
subject
=
"带附件的邮件测试程序"
;
String
content
=
"发送邮件测试"
;
String
content
=
"发送邮件测试"
;
String
copyAddress
=
"
825290417@qq.com,chenweiyang@zhiweidata.com"
;
String
copyAddress
=
"
chenweiyang@zhiweidata.com"
;
List
<
String
>
attachFileNames
=
new
ArrayList
<
String
>();
List
<
String
>
attachFileNames
=
new
ArrayList
<
String
>();
attachFileNames
.
add
(
"
E://数据//2017年数据//9月份数据//南京组-美团日报数据//南京组-美团日报数据2017-09-28-微博.xlsx"
);
attachFileNames
.
add
(
"
C:\\Users\\admin\\Desktop\\质检数据-大词-2020-04-13.xlsx"
);
MailInfo
mailInfo
=
new
MailInfo
(
mailServerHost
,
mailServerPort
,
fromAddress
,
fromName
,
toAddress
,
userName
,
password
,
MailInfo
mailInfo
=
new
MailInfo
(
mailServerHost
,
mailServerPort
,
fromAddress
,
fromName
,
toAddress
,
userName
,
password
,
validate
,
subject
,
content
,
copyAddress
,
attachFileNames
);
validate
,
subject
,
content
,
copyAddress
,
attachFileNames
);
...
...
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