【问题标题】:Connect to Microsoft Exchange Server with Spring Integration Mail使用 Spring Integration Mail 连接到 Microsoft Exchange Server
【发布时间】:2012-05-02 14:46:18
【问题描述】:

我想使用 Spring Integration Mail 通过 IMAP 连接到 Microsoft Exchange 2010。 我的问题是连接字符串到底长什么样。

假设:

domain=earth
user=jdoe
email=jon.doe@earth.com
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:jdoespw@example.mailhost.com/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" />

【问题讨论】:

    标签: spring exchange-server spring-integration


    【解决方案1】:

    现在发现了。它不必对连接字符串做任何事情。 对于那些想要连接到 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

    【讨论】:

      【解决方案2】:
      1. imaps:// 之后的第一个节点需要是服务器的 fqdn,而不是域(例如 email.earth.com)。
      2. 这里有一个关于交换凭证的常见问题解答http://www.oracle.com/technetwork/java/faq-135477.html
      3. IIRC,IMAP 在 Exchange 上默认启用,管理员必须启用它。

      【讨论】:

      • fqdn后的连接字符串格式会怎样?
      • 对不起;我误读了您的网址 - 我看到您有 user@fqdn。该常见问题解答似乎说您需要 domain\user\emailid@fqdn
      猜你喜欢
      • 2011-12-27
      • 1970-01-01
      • 2021-09-14
      • 1970-01-01
      • 2018-12-05
      • 2016-07-14
      • 2011-09-13
      • 2015-09-03
      • 1970-01-01
      相关资源
      最近更新 更多