如何使用Javamail访问其他邮箱(IMAP,Exchange 2010) [英] How to use Javamail for accessing additional mailboxes (IMAP, Exchange 2010)
问题描述
我想使用带有普通登录的IMAP通过Javamail API(1.4.5)访问共享邮箱(NOT FOLDER).邮件服务器是Exchange Server 2010.
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.
用户:user1(user1@domain.com) 密码:xxxx
User: user1 (user1@domain.com) pwd: xxxx
共享邮箱:shared_MB@domain.com
shared mailbox: shared_MB@domain.com
我设法访问了user1-邮箱:
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);
属性:
mail.imaps.socketFactory.port = 993
mail.imaps.socketFactory.port = 993
mail.imaps.starttls.enable = true
mail.imaps.starttls.enable = true
mail.imaps.socketFactory.class = javax.net.ssl.SSLSocketFactory
mail.imaps.socketFactory.class = javax.net.ssl.SSLSocketFactory
mail.imaps.socketFactory.fallback = false
mail.imaps.socketFactory.fallback = false
用户名= user1@domain.com
username = user1@domain.com
密码= 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
username=user1@domain.com/shared_MB
->不幸的是,我收到"NO AUTHENTICATE"消息:
--> unfortunately I´m getting an "NO AUTHENTICATE" message:
DEBUG IMAP: AUTHENTICATE PLAIN command result: A1 NO AUTHENTICATE failed.
我能够使用Thunderbird进行访问,所以我认为我的代码中缺少某些内容...
I was able to get access with Thunderbird, so I think there is something missing in my code...
推荐答案
我正在执行以下操作,并且对我来说效果很好
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");
这里
DOMAIN \\ USER \\ SHAREDACCOUNT会像这样
假设电子邮件帐户是tarun@abc.com,那么
abc \\ tarun \\ shared_MB
Here
DOMAIN\\USER\\SHAREDACCOUNT would be like this
suppose email account is tarun@abc.com then
abc\\tarun\\shared_MB
您还必须输入tarun@abc.com帐户的密码.
You have to also enter the password of tarun@abc.com account.
这篇关于如何使用Javamail访问其他邮箱(IMAP,Exchange 2010)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!