📄 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 + -