import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
public class receivemail {
public static void main(String[] args) throws Exception {
Properties props = new Properties();
Session recesession = Session.getDefaultInstance(props, null);
recesession.setDebug(true);
Store store = recesession.getStore("pop3");
String user = "****";//帐户
String password = "*****";//密码
store.connect("pop.163.com", user, password);
Folder folder = store.getFolder("INBOX");
folder.open(Folder.READ_ONLY);
Message[] msgs = folder.getMessages();
for (int msgNum = 0; msgNum < msgs.length; msgNum++) {
System.out.println(msgs[msgNum].getSentDate());
System.out.println(msgs[msgNum].getSubject());
System.out.println(msgs[msgNum].getContent());
}
folder.close(false);
store.close();
}
}