spring - 使用 Spring Integration Mail 连接到 Microsoft Exchange Server

标签 spring exchange-server spring-integration

我想使用 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/

相关文章:

java - Spring Security 和 OAuth2 生成具有自定义授权类型的 token

c# - SmtpClient.Send随机导致SmtpException 4.7.0等待客户端输入超时

c# - 自动发现本地异常 : The Autodiscover service couldn't be located

web-services - 与演示 Exchange Server 2007 交谈

junit - 如何对 Spring IntegrationFlow 进行单元测试?

java - 动态设置ftp的属性:inbound-channel-adapter using java code

spring - 使用另一个类的静态方法创建 bean

java - 在 `WEB-INF/lib` 文件夹和 `src/main/resources` 文件夹中找不到 jar 文件的解决方案?

java - 第三方 Spring Boot Starter 命名哪个比较好

java - 如何让 Spring Integration FTP 消息源直接生成 Message<String> 到 channel ,而不是创建文件