无法使用IMAPS协议访问邮箱使用

问题描述:

在此我试图访问使用IMAPS协议的邮箱。无法使用IMAPS协议访问邮箱使用

public static void main(String[] args) throws MessagingException { 
    Properties props = new Properties(); 
    props.put("mail.store.protocol", "imaps"); 
    props.put("mail.imaps.port", "993"); 
    props.put("mail.imaps.starttls.enable", "true"); 
    Session session = Session.getDefaultInstance(props); 
    Store store = session.getStore("imaps"); 

    store.connect("imap-mail.outlook.com", "[email protected]","xxxx"); 
    Folder elisa = store.getFolder("Inbox"); 
    System.out.println("No of unread Mail " + elisa.getUnreadMessageCount()); 
} 

错误,我得到的是:

Exception in thread "main" javax.mail.AuthenticationFailedException: [AUTHENTICATIONFAILED] Invalid username or password. 
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:665) 
    at javax.mail.Service.connect(Service.java:295) 
    at javax.mail.Service.connect(Service.java:176) 
    at sid.test.email.EmailMain.main(EmailMain.java:21) 
+0

请以更好的方式问[如何问](http://*.com/help/how-to-ask)。 添加一个问题和一个错误(如果存在)。 – GAlexMES

+0

对不起。但你知道答案吗? –

+0

我应该如何知道你从未问过的问题的答案? 你有什么样的问题? “不能”不是真正有用的。 – GAlexMES

根据https://www.lifewire.com/outlook-imap-server-settings-1170672 你应该使用完整Outlook.com电子邮件地址(非别名)。 您使用outlook.com电子邮件地址,而不是emailid @domain.com