-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
11 additions
and
8 deletions.
There are no files selected for viewing
Binary file modified
BIN
-6 Bytes
(100%)
WebContent/WEB-INF/classes/com/lanling/servlet/YouXiangServlet.class
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
WebContent/WEB-INF/classes/com/lanling/util/SendEmilUtil$1.class
Binary file not shown.
Binary file modified
BIN
+283 Bytes
(110%)
WebContent/WEB-INF/classes/com/lanling/util/SendEmilUtil.class
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
package com.lanling.util; | ||
|
||
import java.io.UnsupportedEncodingException; | ||
import java.util.Properties; | ||
|
||
import javax.mail.Authenticator; | ||
|
@@ -13,7 +14,7 @@ | |
|
||
public class SendEmilUtil { | ||
|
||
public static boolean sendEmail(String emailTo,String head,String content) { | ||
public static boolean sendEmail(String emailTo,String head,String content) throws UnsupportedEncodingException { | ||
Properties properties = System.getProperties(); | ||
properties.setProperty("mail.smtp.host", "smtp.163.com"); | ||
properties.put("mail.smtp.auth", "true"); | ||
|
@@ -32,13 +33,14 @@ public PasswordAuthentication getPasswordAuthentication(){ | |
MimeMessage message = new MimeMessage(session); | ||
try { | ||
// Set From: 头部头字段 | ||
message.setFrom(new InternetAddress("[email protected]")); | ||
message.setFrom(new InternetAddress("[email protected]","小胡","utf-8")); | ||
// Set To: 头部头字段 | ||
message.addRecipient(Message.RecipientType.TO,new InternetAddress(emailTo)); | ||
// Set Subject: 头部头字段 | ||
message.setSubject(head); | ||
message.setSubject(head,"utf-8"); | ||
// 设置消息体 | ||
message.setText(content); | ||
// message.setText(content); | ||
message.setContent(content, "text/plain;charset=utf-8"); //生成邮件正文 | ||
// 发送消息 | ||
Transport.send(message); | ||
return true; | ||
|