jsp邮件发送

package com.xl.action;

import java.io.IOException;
import java.util.Date;
import java.util.Properties;

import javax.mail.BodyPart;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Multipart;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeBodyPart;
import javax.mail.internet.MimeMessage;
import javax.mail.internet.MimeMultipart;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class TxEmail extends HttpServlet {

/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request the request send by the client to the server
* @param response the response send by the server to the client
* @throws ServletException if an error occurred
* @throws IOException if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request,response);
}


public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String content=new String(request.getParameter("content").getBytes("iso-8859-1"));
String tal=new String(request.getParameter("tal").getBytes("iso-8859-1"));
String tx_email =request.getParameter("email");//发送人EAMIL
String pass =new String(request.getParameter("pass").getBytes("iso-8859-1"));//EMAIL密码
String addres=new String(request.getParameter("addres").getBytes("iso-8859-1"));//住址
String tto=request.getParameter("tto");//收件人地址
try{
String type_email=tx_email.substring(tx_email.lastIndexOf("@")+1, tx_email.lastIndexOf("."));
System.out.println(tx_email+" "+pass+" 0.0.0.0.0..0.0..");
String ttitle="公司网站有留言,请注意查看!";
//String tcontent="<hr><br/><object classid=clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95 codebase='http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,1,5,217' id=MediaPlayer type=application/x-oleobject width=210 height=340 standby='Loading Microsoft Windows Media Player components...' VIEWASTEXT align=MIDDLE><param name=AudioStream value=-1><param name=AutoSize value=0><param name=AutoStart value=1> <param name=AnimationAtStart value=0><param name=AllowScan value=-1><param name=AllowChangeDisplaySize value=0><param name=AutoRewind value=0><param name=Balance value=0><param name=BaseURL value=''><param name=BufferingTime value=5><param name=CaptioningID value=''><param name=ClickToPlay value=0><param name=CursorType value=32512><param name=CurrentPosition value=-1><param name=CurrentMarker value=0><param name=DefaultFrame value=1><param name=DisplayBackColor value=0><param name=DisplayForeColor value=16777215><param name=DisplayMode value=0><param name=DisplaySize value=0><param name=Enabled value=-1><param name=EnableContextMenu value=-1><param name=EnablePositionControls value=0><param name=EnableFullScreenControls value=0><param name=EnableTracker value=1><param name=Filename value='http://down.twochong.com/20090102193927250.mp3'><param name=InvokeURLs value=-1><param name=Language value=-1><param name=Mute value=0><param name=PlayCount value=1><param name=PreviewMode value=0><param name=Rate value=1><param name=SAMILang value=''><param name=SAMIStyle value=''><param name=SAMIFileName value=''><param name=SelectionStart value=0><param name=SelectionEnd value=true>param name=SendOpenStateChangeEvents value=-1><param name=SendWarningEvents value=-1><param name=SendErrorEvents value=-1><param name=SendKeyboardEvents value=0><param name=SendMouseClickEvents value=0><param name=SendMouseMoveEvents value=0><param name=SendPlayStateChangeEvents value=-1><param name=ShowCaptioning value=0><param name=ShowControls value=1><param name=ShowAudioControls value=1><param name=ShowDisplay value=1><param name=ShowGotoBar value=1><param name=ShowPositionControls value=1><param name=ShowStatusBar value=1><param name=ShowTracker value=1><param name=TransparentAtStart value=0><param name=VideoBorderWidth value=0><param name=VideoBorderColor value=0><param name=VideoBorder3D value=0><param name=Volume value=-1070><param name=WindowlessVideo value=1></object><br/>aaaaa";
String tcontent="电话:"+tal+"<br>邮箱:"+tx_email+"<br>地址:"+addres+"<br>"+"留言内容:"+content;

Properties props=new Properties();
props.put("mail.smtp.host","smtp."+type_email+".com");
props.put("mail.smtp.auth","true");
Session s=Session.getInstance(props);
s.setDebug(true);

MimeMessage message=new MimeMessage(s);

// 给消息对象设置发件人/收件人/主题/发信时间

InternetAddress from=new InternetAddress(tx_email);
message.setFrom(from);
InternetAddress to=new InternetAddress(tto);
message.setRecipient(Message.RecipientType.TO,to);
message.setSubject(ttitle);
message.setSentDate(new Date());


// 给消息对象设置内容
BodyPart mdp=new MimeBodyPart();//新建一个存放信件内容的BodyPart对象
mdp.setContent(tcontent,"text/html;charset=utf-8");//给BodyPart对象设置内容和格式/编码方式
Multipart mm=new MimeMultipart();//新建一个MimeMultipart对象用来存放BodyPart对
// 象(事实上可以存放多个)
mm.addBodyPart(mdp);//将BodyPart加入到MimeMultipart对象中(可以加入多个BodyPart)
message.setContent(mm);//把mm作为消息对象的内容521loveshitou. microsoft_hang@sina.com

message.saveChanges();
Transport transport=s.getTransport("smtp");
transport.connect("smtp."+type_email+".com",tx_email,pass);
transport.sendMessage(message,message.getAllRecipients());
transport.close();
System.out.println("发送成功!");
}catch (Exception e){
e.printStackTrace();
// TODO: handle exception
}



System.out.println("发送成功!!!!");
request.getRequestDispatcher("Main.jsp").forward(request, response);


}

}
内容概要:本书《Deep Reinforcement Learning with Guaranteed Performance》探讨了基于李雅普诺夫方法的深度强化学习及其在非线性系统最优控制中的应用。书中提出了一种近似最优自适应控制方法,结合泰勒展开、神经网络、估计器设计及滑模控制思想,解决了不同场景下的跟踪控制问题。该方法不仅保证了性能指标的渐近收敛,还确保了跟踪误差的渐近收敛至零。此外,书中还涉及了执行器饱和、冗余解析等问题,提出了新的冗余解析方法,验证了所提方法的有效性和优越性。 适合人群:研究生及以上学历的研究人员,特别是从事自适应/最优控制、机器人学和动态神经网络领域的学术界和工业界研究人员。 使用场景及目标:①研究非线性系统的最优控制问题,特别是在存在输入约束和系统动力学的情况下;②解决带有参数不确定性的线性和非线性系统的跟踪控制问题;③探索基于李雅普诺夫方法的深度强化学习在非线性系统控制中的应用;④设计和验证针对冗余机械臂的新型冗余解析方法。 其他说明:本书分为七章,每章内容相对独立,便于读者理解。书中不仅提供了理论分析,还通过实际应用(如欠驱动船舶、冗余机械臂)验证了所提方法的有效性。此外,作者鼓励读者通过仿真和实验进一步验证书中提出的理论和技术。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值