使用IMAP的基本Java Mail会话在连接到Exchange时抛出不支持的记录版本

时间:2016-04-29 21:16:02

标签: java email ssl javamail

我使用IMAPS连接到Microsoft Exchange 2003服务器并尝试检索新邮件,从而简单地设置了Java邮件。

    Properties props = new Properties();
    props.setProperty("mail.imap.host", mailUser.getUrl());
    props.setProperty("mail.imap.connectiontimeout", MAIL_TIMEOUT_MS);
    props.setProperty("mail.store.protocol", "imaps");
    props.setProperty("mail.imap.auth.ntlm.disable", "true");
    javax.mail.Session mailSession = javax.mail.Session.getInstance(props);
    mailSession.setDebug(false);
    Store store = mailSession.getStore();
    Folder inbox = null;
    try
    {
        byte[] encryptedPassword = mailUser.getEncryptedPassword();
        String encryptedPasswordStr = encryptedPassword == null ? "" : new String(encryptedPassword);
        store.connect(mailUser.getUrl(), mailUser.getUsername(), encryptedPasswordStr);
        inbox = store.getFolder(INBOX_FOLDER_NAME);
        inbox.open(Folder.READ_WRITE);
        int unreadMessageCount = inbox.getUnreadMessageCount();
        if (unreadMessageCount > 0)
        {
            Message[] mailMessages = inbox.search(new FlagTerm(new Flags(Flags.Flag.SEEN), false));
            for (javax.mail.Message mailMessage : mailMessages)
            {
                try
                {
                    processMessage(mailMessage);
                }
                catch (ParseException e)
                {
                    LOGGER.error("Unable to parse message header for message.  Skipping", e.getMessage());
                }
            }
        }
    }
    finally
    {
        store.close();
    }

正确创建了SSL Imap存储,但是当调用connect时,SSL连接得到正确设置,所有证书部分在java日志中看起来都很好,然后在建立连接后出现此错误:

INFO  [AbstractLoggingWriter] EJB default - 1, handling exception: javax.net.ssl.SSLException: Unsupported record version Unknown-11.48
INFO  [AbstractLoggingWriter] %% Invalidated:  [Session-25, SSL_RSA_WITH_3DES_EDE_CBC_SHA]
INFO  [AbstractLoggingWriter] EJB default - 1, SEND TLSv1 ALERT:fatal, description = unexpected_message

客户端问候,服务器问候和服务器问候已经完成并且看起来很好。 IMAP登录Exchange服务器只报告成功的连接。有什么想法吗?

0 个答案:

没有答案