?? mypop3.java
字號:
import java.io.*;
import java.net.*;
import java.util.*;
public class mypop3{
public static void main(String[]args)throws IOException,UnknownHostException{
String mailHost;
mailHost="pop3.163.com";
POP3Connection mail =new POP3Connection(mailHost);
mail.Receive();
}
}
class POP3Connection
{
final static int PORT=110;
static InetAddress r_ip;
public POP3Connection(String host)throws UnknownHostException{
r_ip=InetAddress.getByName(host);
}
public boolean Receive()throws IOException
{
// Create Socket
BufferedReader in,msg;
DataOutputStream out;
Socket sock;
String result,line,pass,name;
if((sock=new Socket(r_ip,PORT))==null)
return false;
in=new BufferedReader(new InputStreamReader(sock.getInputStream()));
out=new DataOutputStream(sock.getOutputStream());
result=in.readLine();
System.out.println(result);
out.writeBytes("HELO"+"bootcool"+"\n");
System.out.println("HELO"+r_ip.getHostAddress()+"\n");
result=in.readLine();
System.out.println(result);
System.out.println("**********");
out.writeBytes("USER"+"bootcool"+"\n");
result=in.readLine();
System.out.println(result);
out.writeBytes("PASS"+"bootcool"+"\n");
result=in.readLine();
System.out.println(result);
out.writeBytes("STAT1"+"\n");
out.writeBytes("LIST1"+"\n");
result=in.readLine();
System.out.println(result);
out.writeBytes("UIDL1 "+"\n");
result=in.readLine();
System.out.println(result);
out.writeBytes("RETR1");
result=in.readLine();
System.out.println(result+"\n");
//out.writeBytes("TOP 1"+"\n");
//result = in.readLine();
//System.out.println(result);
//out.writeBytes("DELE 1"+"\n");
//result = in.readLine();
//System.out.println(result);
out.writeBytes("QUIT"+"\n");
System.out.println("QUIT");
result=in.readLine();
System.out.println(result);
sock.close();
return true;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -