[英]Logging into multiple gmail accounts to read messages in inbox in java using imaps
我是新手,正在編寫一個程序,該程序登錄我的g-mail帳戶並檢查“收件箱”中的消息。 為此,我使用了imaps ("imaps.gmail.com")
。 但是我的問題是登錄所有帳戶時,一一檢查其中的消息。
程序報告以下錯誤/種類:javax.mail.AuthenticationFailedException:[ALERT]請通過您的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在個人資料訪問甚至郵件訪問方面都保持高度的安全性,但即使是用戶可以使用以下鏈接來控制它,也可以對其進行安全控制
轉到帶有您的Google帳戶的鏈接,然后選擇“打開”,然后嘗試執行您的程序。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.