用于连接的代码:
Properties properties = System.getProperties();
properties.setProperty("mail.store.protocol", "imaps");
properties.setProperty("mail.imap.starttls.enable", "true");
String host = "imap.mail.me.com";
int port = 993;
String result = null;
TestLogger.log("Connecting to Imap..");
try {
//Connect to the server
Session session = Session.getInstance(properties);
session.setDebug(true);
Store store = session.getStore();
store.connect(host, port, "username","pass");
store.connect抛出A0 BAD Parse Error,完整的调试输出:
Attempt #0
Connecting to Imap..
DEBUG: setDebug: JavaMail version 1.4.7
DEBUG: getProvider() returning javax.mail.Provider[STORE,imaps,com.sun.mail.imap.IMAPSSLStore,Oracle]
DEBUG IMAPS: mail.imap.fetchsize: 16384
DEBUG IMAPS: mail.imap.ignorebodystructuresize: false
DEBUG IMAPS: mail.imap.statuscachetimeout: 1000
DEBUG IMAPS: mail.imap.appendbuffersize: -1
DEBUG IMAPS: mail.imap.minidletime: 10
DEBUG IMAPS: trying to connect to host "imap.mail.me.com", port 993, isSSL true
* OK
DEBUG IMAPS: AUTH: ATOKEN
DEBUG IMAPS: AUTH: PLAIN
DEBUG IMAPS: protocolConnect login, host=imap.mail.me.com, user=<user>, password=<non-null>
DEBUG IMAPS: AUTHENTICATE PLAIN command trace suppressed
DEBUG IMAPS: AUTHENTICATE PLAIN command result: A0 BAD Parse Error
***** ERROR *****: Error
***** ERROR *****: javax.mail.MessagingException: A0 BAD Parse Error;
nested exception is:
com.sun.mail.iap.BadCommandException: A0 BAD Parse Error
at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:668)
at javax.mail.Service.connect(Service.java:295)
at