我想使用 Spring Integration Mail 通过 IMAP 连接到 Microsoft Exchange 2010。 我的问题是连接字符串到底是什么样的。
比方说:
domain=earth
user=jdoe
<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="63060e020a0f5e090c0d4d070c0623060211170b4d000c0e" rel="noreferrer noopener nofollow">[email protected]</a>
Folder=inbox
据我所知,MS Exchange 仅支持 imap 连接。
我的 Spring 集成配置如下所示:
<util:properties id="javaMailProperties">
<prop key="mail.imaps.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imaps.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.debug">true</prop>
</util:properties>
<mail:inbound-channel-adapter id="imapAdapter"
store-uri="imaps://earth/jdoe/jon.doe:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3b515f545e484b4c7b5e435a564b575e15565a52575354484f15585456" rel="noreferrer noopener nofollow">[email protected]</a>/inbox" channel="recieveEmailChannel"
should-delete-messages="false" should-mark-messages-as-read="true"
auto-startup="true" java-mail-properties="javaMailProperties">
<int:poller fixed-delay="5"
time-unit="SECONDS" />
</mail:inbound-channel-adapter>
<int:channel id="recieveEmailChannel" />
<int:service-activator input-channel="recieveEmailChannel"
ref="mailReceiver" method="receive" />
<bean id="mailReceiver"
class="com.earth.MailReceiver" />
最佳答案
现在发现了。它不必对连接字符串执行任何操作。 对于那些想要连接到 Exchange 的人,这里有一些提示。
这是我的配置:
<util:properties id="javaMailProperties">
<prop key="mail.imaps.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
<prop key="mail.imap.starttls.enable">true</prop>
<prop key="mail.imaps.socketFactory.fallback">false</prop>
<prop key="mail.store.protocol">imaps</prop>
<prop key="mail.debug">true</prop>
</util:properties>
<mail:inbound-channel-adapter id="imapAdapter"
store-uri="imap://<username>:<password>@<exchange-url>/INBOX" channel="recieveEmailChannel"
should-delete-messages="false" should-mark-messages-as-read="false"
auto-startup="true" java-mail-properties="javaMailProperties">
<int:poller fixed-delay="5"
time-unit="SECONDS" />
</mail:inbound-channel-adapter>
<int:channel id="recieveEmailChannel" />
<int:service-activator input-channel="recieveEmailChannel"
ref="reviewMailService" method="receive" />
通常,Exchange 使用具有 STARTTLS 连接的 Imap。
要执行 SSL 握手,您可以使用 InstallCert Java 程序: http://code.google.com/p/java-use-examples/source/browse/trunk/src/com/aw/ad/util/InstallCert.java
关于spring - 使用 Spring Integration Mail 连接到 Microsoft Exchange Server,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10416142/