Mit JavaMail eine Verbindung zu einem Exchange-server mit IMAP aktiv

Ich bin mit JavaMail 1.5.1 Anschluss an mehrere E-Mail-Konten (unterschiedliche Anbieter, etc). Es sieht perfekt aus für viele Dienste, aber ich habe Probleme eine Verbindung herstellen möchten, ein paar von Ihnen. Beide scheint die gleiche Antwort.

Einer der Dienste, die sind, gebe mir Mühe wird durch apptix.com. Wie ich gelesen habe, von Ihren online-docs (Seite 21) die smtp - /imap-Einstellungen sind die folgenden:

  • smtp-host: smtp.apptixemail.net
  • smtp-port: 587
  • TLS

  • imap host: imap.apptixemail.net

  • imap-port: 993
  • SSL

Habe ich den Benutzer und das Kennwort für meine test-user. Ich bin in der Lage, eine Verbindung zu SMTP -, nicht aber für IMAP. Hier ist mein code, um die Verbindung zu IMAP -

public static IMAPStore connectToImap(String host, int port, String username, String password) throws MessagingException {
    Properties props = System.getProperties();
    props.setProperty("mail.imap.sasl.enable", "true");
    props.setProperty("mail.imap.starttls.enable", "true");

    props.setProperty("mail.imap.auth.ntlm.disable", "true");
    props.setProperty("mail.imap.auth.plain.disable", "true");
    props.setProperty("mail.imap.auth.gssapi.disable", "true");
    props.setProperty("mail.imap.ssl.enable", "true");

    Session imapSession = Session.getInstance(props);
    IMAPStore store = new IMAPStore(imapSession, null);
    store.connect(host, port, username, password);

    return store;
}

Und hier ist die Spur, die ich bin immer nach der Ausführung der Methode, um eine Verbindung zum SMTP-und IMAP -

DEBUG: setDebug: JavaMail version 1.5.1
DEBUG SMTP: useEhlo true, useAuth false
DEBUG SMTP: trying to connect to host "smtp.apptixemail.net", port 587, isSSL false
220 smtp.apptixemail.net Microsoft ESMTP MAIL Service ready at Fri, 11 Apr 2014 19:50:15 -0500
DEBUG SMTP: connected to host "smtp.apptixemail.net", port: 587

EHLO 10.58.0.246
250-smtp.apptixemail.net Hello [10.2.64.1]
250-SIZE 57671680
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-STARTTLS
250-AUTH LOGIN
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "57671680"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "STARTTLS", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
STARTTLS
220 2.0.0 SMTP server ready
EHLO 10.58.0.246
250-smtp.apptixemail.net Hello [10.2.64.1]
250-SIZE 57671680
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-AUTH LOGIN
250-8BITMIME
250-BINARYMIME
250 CHUNKING
DEBUG SMTP: Found extension "SIZE", arg "57671680"
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "AUTH", arg "LOGIN"
DEBUG SMTP: Found extension "8BITMIME", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Attempt to authenticate using mechanisms: LOGIN PLAIN DIGEST-MD5 NTLM 
DEBUG SMTP: AUTH LOGIN command trace suppressed
DEBUG SMTP: AUTH LOGIN succeeded
DEBUG: setDebug: JavaMail version 1.5.1
DEBUG IMAP: mail.imap.fetchsize: 16384
DEBUG IMAP: mail.imap.ignorebodystructuresize: false
DEBUG IMAP: mail.imap.statuscachetimeout: 1000
DEBUG IMAP: mail.imap.appendbuffersize: -1
DEBUG IMAP: mail.imap.minidletime: 10
DEBUG IMAP: disable AUTH=PLAIN
DEBUG IMAP: disable AUTH=NTLM
DEBUG IMAP: enable STARTTLS
DEBUG IMAP: enable SASL
DEBUG IMAP: trying to connect to host "imap.apptixemail.net", port 993, isSSL true
* OK The Microsoft Exchange IMAP4 service is ready.
A0 CAPABILITY
* CAPABILITY IMAP4 IMAP4rev1 AUTH=NTLM AUTH=GSSAPI AUTH=PLAIN CHILDREN IDLE NAMESPACE LITERAL+
A0 OK CAPABILITY completed.
DEBUG IMAP: AUTH: NTLM
DEBUG IMAP: AUTH: GSSAPI
DEBUG IMAP: AUTH: PLAIN
DEBUG IMAP: protocolConnect login, host=imap.apptixemail.net, user=XXX@YYY.com, password=<non-null>
DEBUG IMAP: SASL authentication command trace suppressed
DEBUG IMAP: SASL Mechanisms:
DEBUG IMAP:  NTLM
DEBUG IMAP:  GSSAPI
DEBUG IMAP:  PLAIN
DEBUG IMAP: 
2014-04-11 17:50:26.614 java[32026:1003] Unable to load realm info from SCDynamicStore
DEBUG IMAP: Failed to create SASL client, THROW: 
javax.security.sasl.SaslException: Failure to initialize security context [Caused by GSSException: Invalid name provided (Mechanism level: Could not load configuration from SCDynamicStore)]
    at com.sun.security.sasl.gsskerb.GssKrb5Client.<init>(GssKrb5Client.java:132)
    at com.sun.security.sasl.gsskerb.FactoryImpl.createSaslClient(FactoryImpl.java:45)
    at javax.security.sasl.Sasl.createSaslClient(Sasl.java:354)
    at com.sun.mail.imap.protocol.IMAPSaslAuthenticator.authenticate(IMAPSaslAuthenticator.java:131)
    at com.sun.mail.imap.protocol.IMAPProtocol.sasllogin(IMAPProtocol.java:765)
    at com.sun.mail.imap.IMAPStore.login(IMAPStore.java:761)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:665)
    at javax.mail.Service.connect(Service.java:345)
    at test.Mailbox.connectToImap(MailboxUtils.java:561)
    at test.TestUserPass.main(TestUserPass.java:470)
Caused by: GSSException: Invalid name provided (Mechanism level: Could not load configuration from SCDynamicStore)
    at sun.security.jgss.krb5.Krb5NameElement.getInstance(Krb5NameElement.java:110)
    at sun.security.jgss.krb5.Krb5MechFactory.getNameElement(Krb5MechFactory.java:80)
    at sun.security.jgss.GSSManagerImpl.getNameElement(GSSManagerImpl.java:188)
    at sun.security.jgss.GSSNameImpl.getElement(GSSNameImpl.java:428)
    at sun.security.jgss.GSSNameImpl.init(GSSNameImpl.java:157)
    at sun.security.jgss.GSSNameImpl.<init>(GSSNameImpl.java:127)
    at sun.security.jgss.GSSManagerImpl.createName(GSSManagerImpl.java:123)
    at com.sun.security.sasl.gsskerb.GssKrb5Client.<init>(GssKrb5Client.java:90)
    ... 9 more
DEBUG IMAP: SASL authentication failed
DEBUG IMAP: LOGIN command trace suppressed
DEBUG IMAP: LOGIN command result: A1 NO LOGIN failed.
Exception in thread "main" javax.mail.AuthenticationFailedException: LOGIN failed.
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:684)
    at javax.mail.Service.connect(Service.java:345)
    at test.Mailbox.connectToImap(MailboxUtils.java:561)
    at test.TestUserPass.main(TestUserPass.java:470)

Frage ich mich, warum Los ist. Ich habe keine Ahnung, warum das nicht funktioniert. Ich weiß nicht, ob es hat etwas zu tun mit der GSSAPI Ausnahme sind, oder ob es etwas anderes ... Da kann man se in den code, den ich deaktiviert habe, ntlm und schlicht (wie vorgeschlagen in der JavaMail-docs), aber nichts.

Haben Sie versucht, das "krb5" Java-system-properties wie bereits hier?
Ja, habe ich. Aber um ganz ehrlich zu sein verstehe ich nicht, was ich in diesen Requisiten.

InformationsquelleAutor plunchete | 2014-04-12

Schreibe einen Kommentar