问题
I want to access a shared mailbox (NOT FOLDER) via Javamail API (1.4.5) using IMAP(s) with plain logon. The mailserver is a Exchange Server 2010.
User: user1 (user1@domain.com) pwd: xxxx
shared mailbox: shared_MB@domain.com
I´ve managed to get access to the user1 - mailbox:
Session session = Session.getInstance(properties, new ExchangeAuthenticator(username, password));
session.setDebug(true);
Store store = session.getStore("imaps");
store.connect(imapHost, username, password);
properties:
mail.imaps.socketFactory.port = 993
mail.imaps.starttls.enable = true
mail.imaps.socketFactory.class = javax.net.ssl.SSLSocketFactory
mail.imaps.socketFactory.fallback = false
username = user1@domain.com
password = xxxx
--> this works just fine! But now i want to access the additional mailbox by changing the login-String:
username=user1@domain.com/shared_MB
--> unfortunately I´m getting an "NO AUTHENTICATE" message:
DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 NO AUTHENTICATE failed.
I was able to get access with Thunderbird, so I think there is something missing in my code...
回答1:
I am doing the following and it is working fine for me
properties = System.getProperties();
properties.setProperty("mail.imaps.auth.plain.disable", "true");
properties.setProperty("mail.imaps.auth.ntlm.disable", "true");
Session session = Session.getInstance(properties, null);
store = session.getStore("imaps");
store.connect("HOST", PORT, "DOMAIN\\USER\\SHAREDACCOUNT","pwd");
Here
DOMAIN\\USER\\SHAREDACCOUNT would be like this
suppose email account is tarun@abc.com then
abc\\tarun\\shared_MB
You have to also enter the password of tarun@abc.com account.
来源:https://stackoverflow.com/questions/11719205/how-to-use-javamail-for-accessing-additional-mailboxes-imap-exchange-2010