1

我正在尝试使用 Javamail Api 连接到 IMAP。我可以通过此代码成功连接到 Gmail,但无法连接到我的大学 ID。

public class MailConnection {
    Folder inbox;

public MailConnection() throws MessagingException{
    Properties props = System.getProperties();
    props.setProperty("mail.store.protocol", "imap");
     try{
         Session session = Session.getInstance(props, null);
         Store store = session.getStore("imap");
         store.connect("mailbox.xyz.com", "emailId@xyz.com", "password");
         System.out.println(store);

         inbox = store.getFolder("Inbox");
         System.out.println("No of Unread Messages : " + inbox.getUnreadMessageCount());
     }
     catch (NoSuchProviderException e){
            e.printStackTrace();
            System.exit(1);
     }
}

当我使用我的 Uni id 时,我收到以下错误消息 -

javax.mail.MessagingException: * BYE ;
  nested exception is:
    com.sun.mail.iap.ConnectionException: * BYE 
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:668)
    at javax.mail.Service.connect(Service.java:295)
    at javax.mail.Service.connect(Service.java:176)
    at MailConnection.<init>(MailConnection.java:21)
    at MailConnection.main(MailConnection.java:34)
Caused by: com.sun.mail.iap.ConnectionException: * BYE 
    at com.sun.mail.iap.Protocol.processGreeting(Protocol.java:223)
    at com.sun.mail.imap.protocol.IMAPProtocol.processGreeting(IMAPProtocol.java:228)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:120)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:111)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:637)
    ... 4 more

我不知道这里出了什么问题。这个 BYE 意味着什么?如何解决这个问题?

4

0 回答 0