As per request of Bill Shannon I hereby post my answer to the question:
I placed the required certificate in the cacerts file of Java (be sure that you know what you are doing)
I changed my properties to:
please note that they are now imap and not imaps// TLS & SSL properties.setProperty("mail.imap.starttls.enable", "true"); properties.setProperty("mail.imap.ssl.enable", "false"); // is now false // removed the trust for ssl // login settings properties.setProperty("mail.imap.auth.ntlm.disable", "true"); properties.setProperty("mail.imap.auth.plain.disable", "true"); properties.setProperty("mail.imap.auth.gssapi.disable", "true"); properties.setProperty("mail.user", credentials.getImapUsername()); properties.setProperty("mail.host", credentials.getRootUrl());
And, for me, it works.
As stated before. This is a very server specific answer and question. I hope it can help other people in their effort to connect their program to their exchange server.
EDIT:
Due to the requirement for support of other mail-servers the code changed:
String protocol = "mail.imap";
switch (encryption){
case SSL:
protocol = protocol + "s";
properties.setProperty(protocol + ".starttls.enable", "false");
properties.setProperty(protocol + ".ssl.enable", "true");
break;
case TLS:
properties.setProperty(protocol + ".starttls.enable", "true");
properties.setProperty(protocol + ".ssl.enable", "false");
break;
case NONE:
properties.setProperty(protocol + ".starttls.enable", "false");
properties.setProperty(protocol + ".ssl.enable", "false");
break;
}
properties.setProperty(protocol + ".auth.ntlm.disable", "true");
properties.setProperty(protocol + ".auth.plain.disable", "true");
properties.setProperty(protocol + ".auth.gssapi.disable", "true");
// other properties you want to set
SSL uses the mail.imaps
and TLS and NONE use the mail.imap