Atitit 命令指令的分类与权限 IMAP协议为例子
目录
1. 指令的作用的权限吧。 全局命令 未认证状态命令 未认证状态命令 选中状态指令 2
1.1. 1.在任何状态下都有效的指令(全局命令):CAPALIBILY,NOOP,LOGOUT。 2
1.2. 2.未认证状态下有效的指令(未认证状态命令):STARTTLS,AUTHENTICATE,LOGIN和全局命令。 2
1.4. 4.在选中状态下有效的指令(选中状态指令):CHECK,CLOSE,EXPUNGE,SEARCH,FETCH,STORE,COPY,UID和全局命令、认证状态命令 2
package aPkg;
import java.io.File;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Store;
import javax.mail.search.BodyTerm;
import javax.mail.search.SubjectTerm;
import org.apache.commons.io.FileUtils;
import com.alibaba.fastjson.JSON;
public class ImapSearch {
public static void main(String[] args) throws Exception {
Session session = Session.getDefaultInstance(System.getProperties(),null);
Store store = session.getStore("imaps");
String string =FileUtils.readFileToString(new File("d:\0db\empwd.txt")) ;
store.connect("imap.qq.com", "attilax2@qq.com", string);
// Get default folder
Folder folder = store.getDefaultFolder();
Folder fld_fulltxt=store.getFolder("fldFull2");
// 以读写模式打开收件箱
fld_fulltxt.open(Folder.READ_WRITE);
System.out.println( "fld_fulltxt.getMessageCount"+fld_fulltxt.getMessageCount());
Message[] getMessages1=fld_fulltxt.getMessages();
Message[] ma=fld_fulltxt.search(new BodyTerm("人工智能") );
for (Message message : ma) {
System.out.println(JSON.toJSONString(message, true));
}
System.out.println("--");
}
}
package aPkg;
import java.io.File;
import org.apache.commons.io.FileUtils;
import org.apache.commons.net.imap.IMAP;
import org.apache.commons.net.imap.IMAP.IMAPChunkListener;
import org.apache.commons.net.imap.IMAPClient;
import org.apache.commons.net.imap.IMAPClient.SEARCH_CRITERIA;
import com.alibaba.fastjson.JSON;
public class ImapSearchApacheNetlib {
public static void main(String[] args) throws Exception {
String string =FileUtils.readFileToString(new File("d:\0db\empwd.txt")) ;
IMAPClient IMAPClient1 = new IMAPClient();
IMAPClient1.connect("imap.qq.com");
IMAPClient1.login("attilax2@qq.com", string);
IMAPClient1.select("fldFull2");
String criteria="人工智能";
//= SEARCH_CRITERIA.TEXT;
// IMAPClient1.
IMAPClient1.setChunkListener(new IMAPChunkListener() {
public boolean chunkReceived(IMAP arg0) {
System.out.println(arg0);
return false;
}
});
System.out.println(IMAPClient1.search(criteria));
// Session session = Session.getDefaultInstance(System.getProperties(),null);
// Store store = session.getStore("imaps");
//
// store.connect(, , string);
// Get default folder
// Folder folder = store.getDefaultFolder();
// Folder fld_fulltxt=store.getFolder("fldFull2");
// // 以读写模式打开收件箱
// fld_fulltxt.open(Folder.READ_WRITE);
// System.out.println( "fld_fulltxt.getMessageCount"+fld_fulltxt.getMessageCount());
// Message[] getMessages1=fld_fulltxt.getMessages();
// Message[] ma=fld_fulltxt.search(new BodyTerm("人工智能") );
// for (Message message : ma) {
// System.out.println(JSON.toJSONString(message, true));
// }
System.out.println("--");
}
}
Java中的IMAP客户端:JavaMailAPI还是ApacheCommonsnet? - 问答 - 云+社区 - 腾讯云.plshldr