我是初学者,我正在写一个程序,它可以登录我的电子邮件账户,检查收件箱里的邮件。我用的是imaps ("imaps.gmail.com")
。但我的问题是,当我登录所有的帐户,检查其中的消息一个接一个。
程序报告错误/类型:javax.mail.AuthenticationFailedException: [ALERT] Please log in via您的web浏览器:一些url(失败)imaps: xxxx@gmail.com第二和其他账户……
从这个我明白的是我不是关闭会议,妥善存储。因此,程序无法检查各自的第二和其余邮件帐户。谁来帮忙(澄清一下)…
和我的代码结构:
public class InboxRead {
public static boolean release = false;
private Session session = null;
public void checkInbox(String username, String password) {
// logging into account using imaps..
Properties props = System.getProperties();
props.setProperty("mail.store.protocol", "imaps");
session = Session.getDefaultInstance(props, null);
store = session.getStore("imaps");
store.connect("imap.gmail.com", username, password);
System.out.println(store);
// reading inbox... closing all folders here
store.close();
session = null;
release = true;
}
public static void main(String[] args) {
for(;;) { // gives no of accounts with credentials..
do {
String username = "xxx@gmail.com";
String password = "xxxx";
InboxRead.checkInbox(username, password);
} while(release);
}
}
}
…
这是Google网关抛出的错误。谷歌在个人资料访问甚至邮件访问方面保持高安全性,但即使这样,用户也可以使用下面的链接来控制谷歌安全控制
用你的Google账号到那个链接,选择"打开",然后试着执行你的程序