Skip to content

Commit

Permalink
2020年2月15日提交
Browse files Browse the repository at this point in the history
  • Loading branch information
Bosshzh committed Feb 15, 2020
1 parent a749bcc commit afd852b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
Binary file not shown.
Binary file modified WebContent/WEB-INF/classes/com/lanling/util/SendEmilUtil$1.class
Binary file not shown.
Binary file modified WebContent/WEB-INF/classes/com/lanling/util/SendEmilUtil.class
Binary file not shown.
6 changes: 3 additions & 3 deletions WebContent/youxiang.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
}
%>
<input type="email" name="email" id="youxiang_email" placeholder="请输入邮箱" value="<%=value %>">
<span id="youxiang_span" ></span><br/>
<span id="youxiang_span" ></span><br/><br/>
<%
if(session.getAttribute("verification") == null){
%>
Expand All @@ -53,7 +53,7 @@
}
%>
<label for="verification">验证码:</label>
<input type="text" name="verification" id="verification"><br>
<input type="text" name="verification" id="verification"><br><br/>
<%
if(session.getAttribute("verification") == null){
%>
Expand Down Expand Up @@ -85,7 +85,7 @@
youxiang_span.innerHTML = "邮箱格式验证通过";
youxiang_form.submit();
  }
}
}
</script>
<%
}
Expand Down
3 changes: 2 additions & 1 deletion src/com/lanling/servlet/YouXiangServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
out.write("<h2>绑定邮箱失败,每个邮箱只能绑定一个账号<a href='/SaveData/youxiang.jsp?username="+username+"&openid="+openid+"'>重试</a></h2>\"</h2>");
}
}else {
out.write("<h2>验证码验证失败,请重试</h2>");
session.removeAttribute("verification");//清楚验证码
out.write("<h2>绑定邮箱失败,<a href='/SaveData/youxiang.jsp?username="+username+"&openid="+openid+"'>重试</a></h2>");
}
}

Expand Down
10 changes: 6 additions & 4 deletions src/com/lanling/util/SendEmilUtil.java
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;
Expand All @@ -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");
Expand All @@ -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;
Expand Down

0 comments on commit afd852b

Please sign in to comment.