Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
邬吉朋
ops
Commits
76616b15
Commit
76616b15
authored
Aug 21, 2024
by
wujipeng
Browse files
优化
parent
9a0fbdda
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main/java/com/ruzhoukj/sms/task/SendEmailExample.java
deleted
100644 → 0
View file @
9a0fbdda
package
com.ruzhoukj.sms.task
;
import
java.util.Properties
;
import
javax.mail.Message
;
import
javax.mail.MessagingException
;
import
javax.mail.Session
;
import
javax.mail.Transport
;
import
javax.mail.internet.InternetAddress
;
import
javax.mail.internet.MimeMessage
;
public
class
SendEmailExample
{
public
static
void
main
(
String
[]
args
)
{
final
String
username
=
"2404263178@qq.com"
;
final
String
password
=
"eryzvsveckiudiee"
;
// QQ Mail SMTP server information
Properties
props
=
new
Properties
();
props
.
put
(
"mail.smtp.auth"
,
"true"
);
props
.
put
(
"mail.smtp.starttls.enable"
,
"true"
);
props
.
put
(
"mail.smtp.host"
,
"smtp.qq.com"
);
props
.
put
(
"mail.smtp.port"
,
"587"
);
Session
session
=
Session
.
getInstance
(
props
,
new
javax
.
mail
.
Authenticator
()
{
@Override
protected
javax
.
mail
.
PasswordAuthentication
getPasswordAuthentication
()
{
return
new
javax
.
mail
.
PasswordAuthentication
(
username
,
password
);
}
});
try
{
Message
message
=
new
MimeMessage
(
session
);
message
.
setFrom
(
new
InternetAddress
(
username
));
// 添加多个收件人
String
[]
toAddresses
=
{
"2404263178@qq.com"
,
"zhuxiang@ruzhoukj.com"
};
message
.
setRecipients
(
Message
.
RecipientType
.
TO
,
InternetAddress
.
parse
(
String
.
join
(
", "
,
toAddresses
)));
message
.
setSubject
(
"ssl证书即将到期"
);
message
.
setText
(
"This is the message body"
);
Transport
.
send
(
message
);
System
.
out
.
println
(
"Email sent successfully to multiple recipients."
);
}
catch
(
MessagingException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
}
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