使用jsp实现App Inventor 2离线版发送修改密码邮件

FsTy 提交于 周一, 08/03/2020 - 16:57

passmail.jsp  2021年8月更新.  代码大部分参考的 https://blog.csdn.net/qq_39444779/article/details/78346116  感谢!

 

<%@ page import="java.security.GeneralSecurityException"%>
<%@ page import="java.util.Properties"%>
<%@ page import="javax.mail.Authenticator"%>
<%@ page import="javax.mail.Message"%>
<%@ page import="javax.mail.MessagingException"%>
<%@ page import="javax.mail.PasswordAuthentication"%>
<%@ page import="javax.mail.Session"%>
<%@ page import="javax.mail.Transport"%>
<%@ page import="javax.mail.internet.InternetAddress"%>
<%@ page import="javax.mail.internet.MimeMessage"%>
<%@ page import="com.sun.mail.util.MailSSLSocketFactory"%>
<%@ page import="javax.servlet.http.HttpServletRequest"%>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>

<%
// 以下变量为用户根据自己的情况设置

String smtphost = "smtp.qq.com";                   // 发送邮件服务器
String smtpuser = "f*****t@qq.com";                // 邮件服务器登录用户名
String smtppswd = "h*************c";               // 邮件服务器登录密码    qq邮箱生成的授权码  
String password="changemeadfadfasdfasdfasdf";      //与WEB-INF\appengine-web.xml中<property name="localauth.mailserver.password" value="changemeadfadfasdfasdfasdf" />一致
                                                   //检查<property name="localauth.mailserver" value="http://127.0.0.1/passmail.jsp" />设置
String TestMe="T";                                 //测试. 为"T"可打开 http://127.0.0.1/passmail.jsp 给自己发送邮件测试设置是否正常,为"F"关闭.
%>

<%
//String MeTest = (String) request.getParameter("MeTest");
String pass = (String) request.getParameter("pass");
String url = (String) request.getParameter("url");
String email =  (String) request.getParameter("email");
String locale =  (String) request.getParameter("locale");
if( TestMe.equals("T")   &&  email == null ){
%>
<!doctype html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta HTTP-EQUIV="pragma" CONTENT="no-cache"/>
    <meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate"/>
    <meta HTTP-EQUIV="expires" CONTENT="0"/>
    <title>PassMail 自测</title>
  </head>
  <body>
  <center>
   <form method=POST >
    <h1>PassMail 自测</h1>
    <p>点击发送邮件按钮,将发送一份测试邮件给: <%= smtpuser %>.</p>
    <input type=hidden name=pass value="<%= password %>">
    <input type=hidden name=MeTest value="TestMe">
    <input type=hidden name=email value="<%= smtpuser %>">
    <input type=Submit value="发送邮件" style="font-size: 300%;"></center>
   </form>
  </center>
 </body>
</html>

 

mail.jar和activation.jar放 \WEB-INF\lib.

最新网络版已经集成.

隐私附件,登陆才能下载