这个,我好象有,给出你的email!!!

解决方案 »

  1.   

    也给我一份吧,
    谢谢!!!
    [email protected]
      

  2.   

    给我一分可以吗?谢谢!!
    [email protected]
      

  3.   

    恩,你的email呢!
    算了,我给你个简单的列子吧
    smtp发送的:<%@ page contentType="text/html; charset=gb2312" %>
    <%@ page language="java" %>
    <%@ page import="java.lang.*,java.io.*,java.util.*,java.net.*,sun.misc.BASE64Encoder" %>
    <%!
    public class Parameters
    {
     public JspWriter out;
     public Socket socket;
     public PrintWriter mailOut;
     public BufferedReader mailIn;
    }
    void sendCommand(Parameters parms,String cmd)throws IOException
    {
     parms.out.println("C:"+cmd);
     parms.mailOut.print(cmd+"\r\n");
     parms.mailOut.flush();
     String line=parms.mailIn.readLine();
     parms.out.println("S:"+line);
     }
     
     void sendData(Parameters parms,String to,String subject,String message)throws IOException
    {
     message="to:"+to+"\r\n"+message;
     message="subject:"+subject+"\r\n"+message;
     parms.out.println(message);
     parms.mailOut.print(message);
     parms.mailOut.print("\r\n.\r\n");
     parms.mailOut.flush();
     String line=parms.mailIn.readLine();
     parms.out.println("S:"+line);
     }
     %>
    <%
     String host=request.getParameter("host");
     if((host==null)||(host.trim().equals("")))
     throw new RuntimeException("no mailhost parameter specified");
     
     String username=request.getParameter("textfield2");
     if((username==null)||(username.trim().equals("")))
     throw new RuntimeException("no username parameter specified"); 
     
     String password=request.getParameter("textfield3");
     if((password==null)||(password.trim().equals("")))
     throw new RuntimeException("no password parameter specified"); String from=request.getParameter("from");
     if((from==null)||(from.trim().equals("")))
     throw new RuntimeException("no from parameter specified"); 
     
     String to=request.getParameter("to");
     if((to==null)||(to.trim().equals("")))
     throw new RuntimeException("no to parameter specified");
     
     String subject=request.getParameter("subject");
     if((subject==null)||(subject.trim().equals("")))
     throw new RuntimeException("no subject parameter specified");
     
     String message=request.getParameter("message");
     if((message==null)||(message.trim().equals("")))
     throw new RuntimeException("no message parameter specified");
     
     out.println("<h3>Send mail log</h3>");
     out.println("<pre>");
     Parameters parms=new Parameters();
     parms.out=out;
     parms.socket=new Socket(host,25);
     parms.mailOut=new PrintWriter(parms.socket.getOutputStream(),true);
     parms.mailIn=new BufferedReader(new InputStreamReader(parms.socket.getInputStream()));
     String encodedPassword = new BASE64Encoder().encode(password.getBytes());
     String encodedusername = new BASE64Encoder().encode(username.getBytes());
     String line=parms.mailIn.readLine();
     parms.out.println("S `````````:"+line);
     sendCommand(parms,"HELO :"+host); 
     sendCommand(parms,"auth login");
     sendCommand(parms,encodedusername);
     sendCommand(parms,encodedPassword); 
     sendCommand(parms,"MAIL FROM:"+from); 
     sendCommand(parms,"RCPT TO:"+to);
     sendCommand(parms,"DATA");
     sendData(parms,to,subject,message);
     sendCommand(parms,"QUIT");
     
     parms.socket.close();
     out.println("</pre>");
     %>
      

  4.   

    pop3的:
    <%@ page contentType="text/html; charset=gb2312" %>
    <%@ page language="java" %>
    <%@ page import="java.lang.*,java.io.*,java.util.*,java.net.*" %>
    <%!
    public class Parameters
    {
     public HttpServletRequest request;
     public JspWriter out;
     public Socket socket;
     public PrintWriter mailOut;
     public BufferedReader mailIn;
    }
    void sendCommand(Parameters parms,String cmd)throws IOException
    {
     parms.out.println("C: "+cmd);
     parms.mailOut.print(cmd+"\r\n");
     parms.mailOut.flush();
     String line=parms.mailIn.readLine();
     parms.out.println("S: "+line);
     }
     
     void getMessage(Parameters parms,int msg)throws IOException
    {
     parms.out.println("Retrieving "+msg);
     sendCommand(parms,"retr "+msg);
     String thisURI=parms.request.getRequestURI();
     String thisPath=parms.request.getRealPath(thisURI);
     File thisFile=new File(thisPath);
     String fileName=thisFile.getParent()+msg+".eml";
     PrintWriter fileOut=new PrintWriter(new FileWriter(fileName));
     for(int i=0;;i++){
     String line=parms.mailIn.readLine();
     if(line.startsWith("."))break;
     //RdStrm=new StreamReader(NetStrm);
     //RdStrm=new StreamReader(NetStrm,System.Text.Encoding.GetEncoding("gb2312"))
     //String line1=new String(line.getBytes(),"gb2312");
     //line = new BASE64Encoder().Convert.Tobase64(line.getBytes());
     //if(i>10)break; fileOut.println(line);
     }
     fileOut.flush();
     fileOut.close();
     }
     %>
    <%
     String host=request.getParameter("textfield");
     if((host==null)||(host.trim().equals("")))
     throw new RuntimeException("no mailhost parameter specified");
     
     String username=request.getParameter("textfield2");
     if((username==null)||(username.trim().equals("")))
     throw new RuntimeException("no username parameter specified"); 
     
     String password=request.getParameter("textfield3");
     if((password==null)||(password.trim().equals("")))
     throw new RuntimeException("no password parameter specified");
     
     out.println("<h3>get mail log</h3>");
     out.println("<pre>");
     Parameters parms=new Parameters();
     parms.request=request;
     parms.out=out;
     parms.socket=new Socket(host,110);
     parms.mailOut=new PrintWriter(parms.socket.getOutputStream());
     parms.mailIn=new BufferedReader(new InputStreamReader(parms.socket.getInputStream()));
     
     String line=parms.mailIn.readLine();
     out.println(line);
      
     sendCommand(parms,"USER "+username);
     sendCommand(parms,"PASS "+password); 
     sendCommand(parms,"STAT");
     sendCommand(parms,"UIDL");
     //sendCommand(parms,"LIST");
    // sendCommand(parms,"RETR 2");
     //sendCommand(parms,"DELE 2");
    // sendCommand(parms,"RSET");
     parms.mailOut.print("LIST"+"\r\n");
     parms.mailOut.flush();
     for(;;)
     {line=parms.mailIn.readLine();
     if(line.startsWith("."))break;
      parms.out.println("S: "+line);
     } Vector messageList=new Vector();
     for(;;)
     {line=parms.mailIn.readLine();
     if(line.startsWith("."))break;
     messageList.addElement(line);
     }
     
     int n=messageList.size(); for(int i=1;i<n;i++)
     {
      getMessage(parms,i);
     //sendCommand(parms,"DELE "+i);
     }
     
     
     
     
     sendCommand(parms,"QUIT"); 
     parms.socket.close();
     out.println("</pre>");
     
     %>
      

  5.   

    恩,veiw页面代码太长,你要么自己研究,要么给出email!
      

  6.   

    太好了,太感谢你了,马上给分!!!
    还有,我重新给你开个贴留我的email,你把全部的代码都给我吧,最好还能有pop3和smtp协议的文档。
      

  7.   

    keen_9,你的程序能否打包给我一份?谢了。