0514-86177077
9:00-17:00(工作日)
String username=request.getParameter("login");String password=request.getParameter("password");Session session2=Session.getInstance(System.getProperties() ,null);Store store=session2.getStore("pop3");
try{ store.connect(host,username+"%nyist.net", password);}catch(javax.mail.AuthenticationFailedException e){content="用户名与密码不匹配";}
store.connect("nyist.net",-1,request.getParameter("username")+"%nyist.net",request.getParameter("password"));
Folder folder = store.getFolder("INBOX");Folder.open (Folder.READ_WRITE);Message message[]=folder.getMessages();FetchProfile fp=new FetchProfile();fp.add(FetchProfile.Item.ENVELOPE);fp.add(FetchProfile.Item.FLAGS);fp.add("X-Mailer");folder.fetch(message,fp);
String contentbody="";Object o=message[j].getContent();
if (message[j].isMimeType("text/plain")) { contentbody=(String)+"/td>"; StringBuffer buf=new StringBuffer(contentbody.length()+6); char ch=' '; for(int p=0;pcontentbody.length();p++)//若遇到换行就转为br> {ch=contentbody.charAt(p); if(ch=='\n')buf.append("br>"); else buf.append(ch); } contentbody=buf.toString();}
else if (message[j].isMimeType("text/html")) contentbody=(String)o+"/td>";
String host = "nyist.net";String from = request.getParameter("from");String to = request.getParameter("to");String subject = request.getParameter("subject");String content = request.getParameter("content");Properties props = System.getProperties();//设置邮件服务props.put("mail.smtp.host", host);Session session2 =Session.getInstance(props, null);
MimeMessage message =new MimeMessage(session2);message.setFrom(new InternetAddress(from));message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));message.setSubject(subject);message.setSentDate(new Date());// create the message partMimeBodyPart messageBodyPart =new MimeBodyPart();
messageBodyPart.setText(content);Multipart multipart = new MimeMultipart();multipart.addBodyPart(messageBodyPart);
for (int i=0;imySmartUpload.getFiles().getCount();i++){ com.jspsmart.upload.File myFile = mySmartUpload.getFiles().getFile(i); if (!myFile.isMissing()) { myFile.saveAs("/upload/" + myFile.getFileName()); count ++;}
for(int i=0;request.getParameter("file"+i)!=null;i++){ messageBodyPart = new MimeBodyPart(); File file=new File("/home/mengyu/ROOT/upload/",request.getParameter("file"+i)); DataSource source =new FileDataSource(file); messageBodyPart.setDataHandler(new DataHandler(source)); messageBodyPart.setFileName(request.getParameter("file"+i)); multipart.addBodyPart(messageBodyPart);}// Put parts in messagemessage.setContent(multipart);
Transport.send(message);
Folder folder=store.getFolder("INBOX");folder.open(Folder.READ_WRITE);Message message[]=folder.getMessages();String msg[]=request.getParameterValues("msg");for(int i=0,n=msg.length;in;i++) message[Double.valueOf(msg[i]).intValue()].setFlag(Flags.Flag.DELETED,true);folder.close(true);
//添加用户Runtime.getRuntime().exec("/home/vpopmail/bin/vadduser"+request.getParameter("username")+"@nyist.net "+request.getParameter("passwd"));//删除用户Runtime.getRuntime().exec("/home/vpopmail/bin/vdeluser"+request.getParameter("username")+"@nyist.net");//修改用户密码Runtime.getRuntime().exec("/home/vpopmail/bin/vpasswd"+request.getParameter("username")+"@nyist.net "+request.getParameter("passwd"));
标签:玉树 潮州 广元 保定 肇庆 绍兴 北海 吴忠
上一篇:JSP学习心得
下一篇:在jsp中用bean和servlet联合实现用户注册、登录