-1

次の例外があります。

  javax.mail.MessagingException: Connect failed;
      nested exception is: 
        java.io.IOException: Connect failed
        at com.sun.mail.pop3.POP3Store.protocolConnect(POP3Store.java:106)
        at javax.mail.Service.connect(Service.java:234)
        at javax.mail.Service.connect(Service.java:135)
        at SimpleReceiver.receive(SimpleReceiver.java:50)
        at SimpleReceiver.main(SimpleReceiver.java:29)

どうすればこの問題を解決できますか? コードは次のとおりです。

Store store = null;
        Folder folder = null;
        try {
            //Get hold of the default session
            Properties props = System.getProperties();
            props.put("mail.store.protocol", "pop3");
            props.put("mail.pop3.port", "25");
            props.put("mail.pop3.host", "admin");
            props.put("mail.pop3.auth", "true");
            //Session session = Session.getDefaultInstance(props, null);
            Session session = Session.getInstance(props);
            //Get hold of a POP3 message store, and connect to it
            store = session.getStore("pop3");
            store.connect("pop3", 25, "admin", "1234");
            //Try to get hold of the default folder --
            folder = store.getDefaultFolder();
            if (folder == null)
                throw new Exception("No default folder");
            // and its INBOX --
            folder = folder.getFolder("INBOX");
            if (folder == null)
                throw new Exception("No POP3 INBOX");
            //Open the folder for read only --
            folder.open(Folder.READ_ONLY);
            // Get the message wrappers and process them --
            Message[] msgs = folder.getMessages();
            for (int msgNum = 0; msgNum < msgs.length; msgNum++) {
                printMessage(msgs[msgNum]);
            }
        } catch (Exception ex) {
            ex.printStackTrace();
        } finally {
            //Close down nicely --
            try {
                if (folder != null)
                    folder.close(false);
                if (store != null)
                    store.close();
            } catch (Exception ex2) {
                ex2.printStackTrace();
            }
        }
    }

それで、なぜ次の例外が発生したのですか:

  javax.mail.MessagingException: Connect failed;
      nested exception is: 
        java.io.IOException: Connect failed

................................................................... ...................................................

4

1 に答える 1

2
store.connect("pop3","admin","Your_Required_Password");

また、次のリンクもご覧ください: 1 & 2

于 2012-08-23T08:16:07.433 に答える