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="Username and password do not match";} |
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;p<contentbody.length();p++)//If a newline is encountered, convert to <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(); //Set the mail service 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 part MimeBodyPart messageBodyPart =new MimeBodyPart(); |
messageBodyPart.setText(content); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); |
for (int i=0;i<mySmartUpload.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 message message.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;i<n;i++) message[Double.valueOf(msg[i]).intValue()].setFlag(Flags.Flag.DELETED,true); folder.close(true); |
//Add userRuntime.getRuntime().exec("/home/vpopmail/bin/vadduser"+request.getParameter("user name")+"@nyist.net "+request.getParameter("passwd")); //Delete userRuntime.getRuntime().exec("/home/vpopmail/bin/vdeluser"+request.getParameter("user name")+"@nyist.net"); //Modify user password Runtime.getRuntime().exec("/home/vpopmail/bin/vpasswd"+request.getParameter("usern ame")+"@nyist.net "+request.getParameter("passwd")); |