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);


}

}
【事件触发一致性】研究多智能体网络如何通过分布式事件驱动控制实现有限时间内的共识(Matlab代码实现)内容概要:本文围绕多智能体网络中的事件触发一致性问题,研究如何通过分布式事件驱动控制实现有限时间内的共识,提供了相应的Matlab代码实现方案。文中探讨了事件触发机制在降低通信负担、提升系统效率方面的优势,重点分析了多智能体系统在有限时间收敛的一致性控制策略,涉及系统模型构建、触发条件设计、稳定性与收敛性分析等核心技术环节。此外,文档还展示了该技术在航空航天、电力系统、机器人协同、无人机编队等多个前沿领域的潜在应用,体现了其跨学科的研究价值和工程实用性。; 适合人群:具备一定控制理论基础和Matlab编程能力的研究生、科研人员及从事自动化、智能系统、多智能体协同控制等相关领域的工程技术人员。; 使用场景及目标:①用于理解和实现多智能体系统在有限时间内达成一致的分布式控制方法;②为事件触发控制、分布式优化、协同控制等课题提供算法设计与仿真验证的技术参考;③支撑科研项目开发、学术论文复现及工程原型系统搭建; 阅读建议:建议结合文中提供的Matlab代码进行实践操作,重点关注事件触发条件的设计逻辑与系统收敛性证明之间的关系,同时可延伸至其他应用场景进行二次开发与性能优化。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值