问题
I got an error like this:
javax.mail.AuthenticationFailedException: [ALERT] Too many simultaneous connections.
I've have been told to log out the session each time. But i don't know how to do it.
Here is my code:
/*...............*/
props.setProperty("mail.store.protocol", "imaps");
session = Session.getInstance(props);
try{
store = session.getStore("imaps");
store.connect("imap.googlemail.com", props.getProperty("userid"),
props.getProperty("password")); // imap.mail.yahoo.com
System.out.println("auth access success");
f = (IMAPFolder[]) store.getDefaultFolder().list("*");
} catch (MessagingException me) {
System.err.print(me);
}
/*................*/
回答1:
Call Folder.close(boolean) to release each folder and call Store.close() to logout.
来源:https://stackoverflow.com/questions/27702629/how-do-i-logout-from-gmail-using-javamail-api